def testMissingFields(self): a = Account("the_key") f = tempfile.TemporaryFile() persistance.writefp(f, [a]) f.seek(0) accounts = persistance.readfp(f) self.assertEqual(len(accounts), 1) found = accounts[0] self.assertEqual(found.key(), "the_key") self.assertEqual(found.note(), None) self.assertEqual(found.username(), None) self.assertEqual(found.password(), None) f.close
def testWritefp(self): a = Account("the_key") a.setNote("the note") a.setUsername("the username") a.setEncryptedPassword("the password") f = tempfile.TemporaryFile() persistance.writefp(f, [a]) f.seek(0) config = SafeConfigParser() config.readfp(f) self.assertEqual(config.sections(), ["the_key"]) self.assertEqual(config.get("the_key", "note"), "the note") self.assertEqual(config.get("the_key", "username"), "the username") self.assertEqual(config.get("the_key", "password"), "the password") f.close