def test_reload_drop_cache(self): defaults = {"TEST": True} user_settings = {"TEST": False} payment_settings = PaymentSettings( user_settings=user_settings, defaults=defaults ) payment_settings.reload() self.assertTrue(payment_settings)
def test_transform_dict_to_obj_dict_if_dict_does_not_in_import_dicts(self): defaults = {"TEMPLATES": {}} user_settings = {"TEMPLATES": {"success": "test.html"}} payment_settings = PaymentSettings( user_settings=user_settings, defaults=defaults ) self.assertIsInstance(payment_settings.TEMPLATES, ObjDict)
def test_return_value_from_user_settings_if_this_defined(self): defaults = {"TEST": True} user_settings = {"TEST": False} payment_settings = PaymentSettings( user_settings=user_settings, defaults=defaults ) self.assertFalse(payment_settings.TEST)
def test_return_value_from_default_if_setting_does_not_defined(self): defaults = {"TEST": True} user_settings = {} payment_settings = PaymentSettings( user_settings=user_settings, defaults=defaults ) self.assertTrue(payment_settings.TEST)
def test_transform_dict_to_import_dict_if_dict_in_import_dicts(self): defaults = {"MODULES": {}} user_settings = {"MODULES": {"payments": "django_pay2"}} import_dicts = ["MODULES"] payment_settings = PaymentSettings( user_settings=user_settings, defaults=defaults, import_dicts=import_dicts ) self.assertIsInstance(payment_settings.MODULES, ImportDict)
def test_raise_error_if_attr_is_not_in_defaults(self): defaults = {"TEST": True} user_settings = {} payment_settings = PaymentSettings( user_settings=user_settings, defaults=defaults ) with self.assertRaises(AttributeError): payment_settings.NOT_EXIST
def test_merge_user_settings_obj_dict_with_defaults(self): defaults = {"MODULES": {"payment": "django_pay2", "tests": "tests"}} user_settings = {"MODULES": {"tests": "testproject"}} payment_settings = PaymentSettings( user_settings=user_settings, defaults=defaults ) self.assertEqual( payment_settings.MODULES, ObjDict({"payment": "django_pay2", "tests": "testproject"}), )
def test_merge_user_settings_import_dict_with_defaults(self): defaults = {"MODULES": {"payment": "django_pay2", "tests": "tests"}} user_settings = {"MODULES": {"tests": "testproject"}} import_dicts = ["MODULES"] payment_settings = PaymentSettings( user_settings=user_settings, defaults=defaults, import_dicts=import_dicts ) self.assertEqual( payment_settings.MODULES, ImportDict({"payment": "django_pay2", "tests": "testproject"}), )