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)
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)
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)
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)
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)
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))
def test_non_existent_settings(self): stngs = BotSettings(settings_id = "NON_EXISTENT") stngs.load() self.assertEqual(stngs.stored, False)
def test_set_settings(self): stngs = BotSettings() stngs.settings = {"language": "cs_CZ"} self.assertEqual(stngs.settings, TEST_SETTINGS_1)
def test_default_settings(self): stngs = BotSettings() self.assertEqual(stngs.settings, TEST_SETTINGS_2)