def test_ok(self): """Test ok setting.""" SETTINGS.check() expected = {'DOWNLOADER': DummyDownloader, 'PARSER': DummyParser, 'DOWNLOADER_PARAMS': {'param_name': 'param_val'}} self.assertEqual(SETTINGS.downloaders, {'dummy': expected})
def test_not_correct_subclass(self): """Test not subclass of AbstractPaymentProcessor.""" with self.assertRaisesRegex(ImproperlyConfigured, '{} is not subclass of AbstractPaymentProcessor'.format( 'django_pain.tests.test_settings.TestProcessorsSetting')): SETTINGS.check()
def test_not_dict(self): """Test not dictionary setting.""" with self.assertRaisesRegex(ImproperlyConfigured, 'PAIN_PROCESSORS must be {}, not {}'.format(dict, list)): SETTINGS.check()
def test_not_str_key(self): """Test dictionary with not str keys.""" with self.assertRaisesRegex(ImproperlyConfigured, 'All keys of PAIN_PROCESSORS must be {}'.format(str)): SETTINGS.check()
def test_non_existing_import(self): with self.assertRaises(ImportError): SETTINGS.check()
def test_ok(self): """Test ok setting.""" SETTINGS.check() self.assertEqual(SETTINGS.processors, {'dummy': DummyPaymentProcessor})
def test_ok(self): SETTINGS.check()
def test_not_a_string(self): with self.assertRaisesMessage(ImproperlyConfigured, 'CALLBACKS must be a list of dotted paths to callables'): SETTINGS.check()
def test_invalid_parser(self): """Test invalid parser.""" expected = "django_pain.tests.test_settings.DummyDownloader is not a subclass of BankStatementParser" with self.assertRaisesRegex(ImproperlyConfigured, expected): SETTINGS.check()
def test_invalid_subsettings(self): """Test invalid subsettings.""" expected = "The key 1 is not of type str." with self.assertRaisesRegex(ImproperlyConfigured, expected): SETTINGS.check()
def test_wrong_keys(self): """Test dictionary with wrong keys.""" expected = "Invalid keys." with self.assertRaisesRegex(ImproperlyConfigured, expected): SETTINGS.check()
def test_not_dict_value(self): """Test dictionary with not dict values.""" expected = "Item dummy's value 1 is not of type dict." with self.assertRaisesRegex(ImproperlyConfigured, expected): SETTINGS.check()
def test_not_str_key(self): """Test dictionary with not str keys.""" expected = 'The key 0 is not of type str.' with self.assertRaisesRegex(ImproperlyConfigured, expected): SETTINGS.check()