Merge lp:~salgado/offspring/object-factory into lp:offspring
Proposed by
Guilherme Salgado
Status: | Merged |
---|---|
Merged at revision: | 89 |
Proposed branch: | lp:~salgado/offspring/object-factory |
Merge into: | lp:offspring |
Prerequisite: | lp:~salgado/offspring/path-independence |
Diff against target: |
118 lines (+112/-0) 1 file modified
lib/offspring/web/queuemanager/tests/factory.py (+112/-0) |
To merge this branch: | bzr merge lp:~salgado/offspring/object-factory |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Kevin McDermott | Approve | ||
Offspring Hackers | Pending | ||
Review via email: mp+76737@code.launchpad.net |
Description of the change
Create a new factory of (django) model objects to be used in tests
To post a comment you must log in.
#1
+ user = User.objects. create_ user( unique_ email_address( ), password)
+ userid, self.get_
+ user.save()
+ return user
This could be simplified to
return User.objects. create_ user(.. .)
The documentation for .create... "A convenience method for creating an object and saving it all in one step"
#2
You alternate between objects.create and direct instantiation throughout the code, any particular reason why?
#3
Can we aim for PEP8 compliance? i.e. "Function names should be lowercase, with words separated by underscores as necessary to improve readability."
def make_projectGrou should be def make_project_group
#4
You've added docstrings to some methods, but not others, can you add docstrings to each method, explaining what they do?
A headsup too...in my database-testing branch, I've removed offspring. config. config, I added get_configuration to offspring.config which returns a ConfigParser-type object, so...
base_dir = config. master( 'result_ directory' )
will become...
config = offspring. config. get_configurati on() get('master' , 'result_directory')
base_Dir = config.
Of course, you can do...
def __init__(...): config. get_configurati on()
...
self.config = offspring.
and then refer to self.config everywhere...
But, in this branch, prior to that getting landed, you can still change the config.master(...) reference to config. get('master' , ...) which is what it's doing.