Esempio n. 1
0
 def test_db_save_user_settings(self):
     stngs = BotSettings(db = ddb, settings_id = settings_id)
     stngs.settings = {"language": "cs_CZ"}
     stngs.save()
     stngs2 = BotSettings(db = ddb, settings_id = settings_id)
     stngs2.load()
     self.assertEqual(stngs.settings, stngs2.settings)
     self.assertEqual(stngs.stored, True)
Esempio n. 2
0
 def test_string(self):
     stngs = BotSettings()
     res_4 = bc.nested_replace_dict(TEST_STRING_1, TEST_REPLACE_2)
     self.assertEqual(res_4, TEST_RES_4)
Esempio n. 3
0
 def test_nested_localize(self):
     stngs = BotSettings()
     res_3 = bc.localize(TEST_DICT_2.copy(), "en_US")
     self.assertEqual(res_3, TEST_RES_3_EN)
     res_3 = bc.localize(TEST_DICT_2.copy(), "cs_CZ")
     self.assertEqual(res_3, TEST_RES_3_CZ)
Esempio n. 4
0
 def test_nested_dict(self):
     stngs = BotSettings()
     res_2 = bc.nested_replace_dict(TEST_DICT_2.copy(), TEST_REPLACE_2)
     self.assertEqual(res_2, TEST_RES_2)
Esempio n. 5
0
 def test_nested(self):
     stngs = BotSettings()
     res_1 = bc.nested_replace(TEST_DICT_1.copy(), "test_1", "aaa")
     self.assertEqual(res_1, TEST_RES_1)
Esempio n. 6
0
 def test_timestamp(self):
     stngs = BotSettings()
     self.assertEqual(stngs.timestamp, datetime.fromtimestamp(0).replace(tzinfo=timezone.utc))
     stngs.save()
     self.assertEqual(stngs.timestamp, datetime.fromtimestamp(stngs.timestamp.timestamp(), timezone.utc))
Esempio n. 7
0
 def test_non_existent_settings(self):
     stngs = BotSettings(settings_id = "NON_EXISTENT")
     stngs.load()
     self.assertEqual(stngs.stored, False)
Esempio n. 8
0
 def test_set_settings(self):
     stngs = BotSettings()
     stngs.settings = {"language": "cs_CZ"}
     self.assertEqual(stngs.settings, TEST_SETTINGS_1)
Esempio n. 9
0
 def test_default_settings(self):
     stngs = BotSettings()
     self.assertEqual(stngs.settings, TEST_SETTINGS_2)