Merge lp:~rvb/maas/maas-basic-model into lp:~maas-committers/maas/trunk
Proposed by
Raphaël Badin
Status: | Merged |
---|---|
Merged at revision: | 14 |
Proposed branch: | lp:~rvb/maas/maas-basic-model |
Merge into: | lp:~maas-committers/maas/trunk |
Diff against target: |
128 lines (+95/-12) 2 files modified
src/maasserver/models.py (+53/-12) src/maasserver/tests/test_models.py (+42/-0) |
To merge this branch: | bzr merge lp:~rvb/maas/maas-basic-model |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Gavin Panella (community) | Approve | ||
Review via email: mp+88890@code.launchpad.net |
Commit message
Update Node and MACAddress.
Description of the change
This branch updates the model classes: Node and MACAddress and adds model tests.
= Tests =
./bin/test
To post a comment you must log in.
Looks good. Lots of questions though :)
[1]
+ def save(self): date.today( ) datetime. today()
+ if not self.id:
+ self.created = datetime.
+ self.updated = datetime.
I assume this needs a sprinkling of pytz? Or does Django mysteriously
DTRT here? I think we should prefer explicit when dealing with dates.
[2]
+def generate_ node_system_ id():
+ return 'node-' + str(uuid1())
return 'node-%s' % uuid1()
might be prettier :) No other reason.
[3]
+ def __unicode__(self):
+ return self.system_id
Is this used by Django, or is it for your own information?
Does Django provide a decent repr around this? In other words, it
would be nice to have a decent repr :)
[4]
+mac_re = re.compile( r'^([0- 9a-fA-F] {2}(:|$ )){6}$' )
I'm not sure about the $ in the middle. It will also match 56:78:90: 12:" even though the max_length setting on mac_address
"12:34:
will catch that.
The following might be clearer:
mac_re = re.compile( r'^([0- 9a-fA-F] {2}:){5} [0-9a-fA- F]{2}$' )
Or even:
mac_re = re.compile( fA-F]{2} :){5} [0-9a-fA-F]{2} $", re.VERBOSE)
r"^ (?:[0-9a-
Note also the non-capturing group I added: (?:...)
[5]
+ self.assertTrue (node.system_ id.startswith( 'node-' ))
Perhaps this is the time to introduce testtools and use StartsWith?
[6]
Docstrings needed!
[7]
+ mac = MACAddress( mac_address= 'AA:BB: CCXDD:EE: FF', node=node) es(ValidationEr ror, mac.full_clean)
+ self.assertRais
Wait! What? It doesn't blow up until later?