def testWriteRead(self): a = Account("the_key") a.setNote("the note") a.setUsername("the username") a.setPassword("the password") path = os.path.join(tempfile.tempdir, "write_test") persistance.write(path, [a]) self.assertTrue(os.path.isfile(path)) accounts = persistance.read(path) self.assertEqual(len(accounts), 1) os.unlink(path)
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
def testUsername(self): a = Account('key') self.assertEqual(a.username(), None) a.setUsername('a user') self.assertEqual(a.username(), 'a user')