コード例 #1
0
ファイル: test_persistance.py プロジェクト: pboyd/passwdr
    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
コード例 #2
0
ファイル: test_persistance.py プロジェクト: pboyd/passwdr
    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