Skip to content

Instantly share code, notes, and snippets.

@moea
Last active August 29, 2015 13:57
Show Gist options
  • Save moea/9766808 to your computer and use it in GitHub Desktop.
Save moea/9766808 to your computer and use it in GitHub Desktop.
Test Style
# instead of
userColl = (yield client.getUserCollection())._coll
self.assertEqual(userColl[0]['userID'],"TestUser")
self.assertEqual(len(userColl[0]['userDeviceAddresses']),2)
self.assertTrue(userColl[0]['userDeviceAddresses'][0]=="DD:DD:DD:DD" or userColl[0]['userDeviceAddresses'][1]=="DD:DD:DD:DD")·
# i would go with something like
(userColl,) = (yield client.getUserCollection())._coll # will assign _coll[0] to userColl and explode unless there is exactly one item
self.assertEqual(userColl['userID'], 'TestUser') # consistent use of either single or double quotes
self.assertEqual(sorted(userColl['userDeviceAddress']), ['AA:AA...', 'DD:DD...']) # more managable than checking each element as above, and checks that both are in there.
# here i'd probably assert something about the timestamp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment