def test_load_from_json(self):
     json_str = "{\"domain\": \"unit.test\", \"username\": \"testilinius\", " +\
                "\"notes\": \"interesting note\", \"legacyPassword\": \"rtSr?bS,mi\", " +\
                "\"usedCharacters\": \"AEIOUaeiou\", \"iterations\": 5341, " +\
                "\"length\": 16, \"salt\": \"ZmFzY2luYXRpbmc=\", " +\
                "\"cDate\": \"2001-01-01T02:14:12\", \"mDate\": \"2005-01-01T01:14:12\"}"
     s = PasswordSetting(json.loads(json_str)["domain"])
     s.load_from_dict(json.loads(json_str))
     self.assertEquals("unit.test", s.get_domain())
     self.assertEquals("testilinius", s.get_username())
     self.assertEquals("interesting note", s.get_notes())
     self.assertEquals("rtSr?bS,mi", s.get_legacy_password())
     self.assertFalse(s.use_lower_case())
     self.assertFalse(s.use_upper_case())
     self.assertFalse(s.use_digits())
     self.assertFalse(s.use_extra())
     self.assertTrue(s.use_custom_character_set())
     self.assertEquals("AEIOUaeiou", s.get_character_set())
     self.assertEquals(5341, s.get_iterations())
     self.assertEquals(16, s.get_length())
     expected_salt = "fascinating".encode('utf-8')
     self.assertEqual(len(expected_salt), len(s.get_salt()))
     for i in range(len(expected_salt)):
         self.assertEqual(expected_salt[i], s.get_salt()[i])
     self.assertEquals("2001-01-01T02:14:12", s.get_creation_date())
     self.assertEquals("2005-01-01T01:14:12", s.get_modification_date())
 def test_load_from_json(self):
     json_str = "{\"domain\": \"unit.test\", \"username\": \"testilinius\", " +\
                "\"notes\": \"interesting note\", \"legacyPassword\": \"rtSr?bS,mi\", " +\
                "\"extras\": \"AEIOUaeiou\", \"iterations\": 5341, " +\
                "\"passwordTemplate\": \"7;xxxxoxxxxxxxxxxx\", \"salt\": \"ZmFzY2luYXRpbmc=\", " +\
                "\"cDate\": \"2001-01-01T02:14:12.000\", \"mDate\": \"2005-01-01T01:14:12.000\"}"
     s = PasswordSetting(json.loads(json_str)["domain"])
     s.load_from_dict(json.loads(json_str))
     self.assertEqual("unit.test", s.get_domain())
     self.assertEqual("testilinius", s.get_username())
     self.assertEqual("interesting note", s.get_notes())
     self.assertEqual("rtSr?bS,mi", s.get_legacy_password())
     self.assertEqual("AEIOUaeiou", s.get_character_set())
     self.assertEqual(5341, s.get_iterations())
     self.assertEqual("xxxxoxxxxxxxxxxx", s.get_template())
     expected_salt = "fascinating".encode('utf-8')
     self.assertEqual(len(expected_salt), len(s.get_salt()))
     for i in range(len(expected_salt)):
         self.assertEqual(expected_salt[i], s.get_salt()[i])
     self.assertEqual("2001-01-01T02:14:12.000", s.get_creation_date())
     self.assertEqual("2005-01-01T01:14:12.000", s.get_modification_date())
 def test_set_modification_date(self):
     s = PasswordSetting("unit.test")
     s.set_creation_date("2007-01-01T02:14:12")
     s.set_modification_date("2005-01-01T01:14:12")
     self.assertEqual("2005-01-01T01:14:12.000", s.get_creation_date())
     self.assertEqual("2005-01-01T01:14:12.000", s.get_modification_date())
 def test_set_modification_date(self):
     s = PasswordSetting("unit.test")
     s.set_creation_date("2007-01-01T02:14:12")
     s.set_modification_date("2005-01-01T01:14:12")
     self.assertEqual("2005-01-01T01:14:12", s.get_creation_date())
     self.assertEqual("2005-01-01T01:14:12", s.get_modification_date())