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 testReadfp(self): f = tempfile.TemporaryFile() for i in range(3): f.write("[key%i]\n" % (i)) f.write("note=note%i\n" % (i)) f.write("username=username%i\n" % (i)) f.write("password=password%i\n" % (i)) f.write("\n") f.seek(0) accounts = persistance.readfp(f) self.assertEqual(len(accounts), 3) i = 0 for a in accounts: self.assertEqual(a.username(), "username%i" % (i)) self.assertEqual(a.password(), "password%i" % (i)) self.assertEqual(a.note(), "note%i" % (i)) i += 1