Merge lp://qastaging/~julian-edwards/maas/mac-address-get-raw-bug-1285233 into lp://qastaging/~maas-committers/maas/trunk

Proposed by Julian Edwards
Status: Merged
Approved by: Julian Edwards
Approved revision: no longer in the source branch.
Merged at revision: 2038
Proposed branch: lp://qastaging/~julian-edwards/maas/mac-address-get-raw-bug-1285233
Merge into: lp://qastaging/~maas-committers/maas/trunk
Diff against target: 59 lines (+28/-6)
2 files modified
src/maasserver/models/macaddress.py (+10/-6)
src/maasserver/models/tests/test_macaddress.py (+18/-0)
To merge this branch: bzr merge lp://qastaging/~julian-edwards/maas/mac-address-get-raw-bug-1285233
Reviewer Review Type Date Requested Status
Jeroen T. Vermeulen (community) Approve
Review via email: mp+208537@code.qastaging.launchpad.net

Commit message

Make sure MACAddress.__unicode__ handles uncleaned mac_address fields

To post a comment you must log in.
Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :

Thanks for the fix. Are you quite sure that the MACAddress constructor won't attempt any cleaning? Might be worth an assertion to confirm. I've seen this go wrong once or twice, where the test didn't actually tickle the problem case and gave us a false sense of security.

review: Approve
Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :

By the way, the code does seem a little bit over-complicated, when you look at how the MAC class fits in. Why not simply:

    def __unicode__(self):
        address = self.mac_address
        if isinstance(address, MAC):
            address = address.get_raw()
        if isinstance(address, bytes):
            address = address.decode('utf-8')
       return address

?

Revision history for this message
Julian Edwards (julian-edwards) wrote :

Thanks jtv. That is simpler indeed. Should not code when tired... :/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.