def test_manager_get_settings_known_value(self): ''' FAIL: test_manager_get_settings_known_value (tests.configuration.tests.ModelTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/travis/build/django-bmf/django-bmf/tests/configuration/tests.py", line 26, in test_manager_get_settings_known_value value = Configuration.get_setting('test', 'test1') File "/home/travis/build/django-bmf/django-bmf/.tox/py34-1.8/lib/python3.4/site-packages/django/test/testcases.py", line 110, in __exit__ query['sql'] for query in self.captured_queries AssertionError: 0 != 1 : 0 queries executed, 1 expected Captured queries were: ''' obj = Configuration(app_label='test', field_name='test1', value='"test1"') obj.save() site.register_settings("test", { 'test1': forms.CharField( max_length=5, ), }) with self.assertNumQueries(1): value = Configuration.get_setting('test', 'test1') self.assertEqual(value, "test1", "Load a known setting value from database") # test loading from cache with self.assertNumQueries(0): value = Configuration.get_setting('test', 'test1') self.assertEqual(value, "test1", "Load a known setting value from cache")
def get_initial(self): self.initial.update({ 'income_account': Configuration.get_setting('bmfcontrib_accounting', 'income'), 'expense_account': Configuration.get_setting('bmfcontrib_accounting', 'expense'), }) return super(ProductCreateView, self).get_initial()
def get_form(self, *args, **kwargs): form = super(ConfigurationEdit, self).get_form(*args, **kwargs) # update initial data form.fields[self.kwargs['name']].initial = Configuration.get_setting( self.kwargs['app_label'], self.kwargs['name'], ) return form
def test_manager_get_settings_new_none(self): site.register_settings("test", { 'test3': forms.CharField( max_length=5, ), }) value = Configuration.get_setting('test', 'test3') self.assertEqual(value, None, "Load a new setting value from database")
def test_manager_get_settings_known_none(self): ''' FAIL: test_manager_get_settings_known_none (tests.configuration.tests.ModelTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/travis/build/django-bmf/django-bmf/tests/configuration/tests.py", line 44, in test_manager_get_settings_known_none value = Configuration.get_setting('test', 'test5') File "/home/travis/build/django-bmf/django-bmf/.tox/py34-1.8/lib/python3.4/site-packages/django/test/testcases.py", line 110, in __exit__ query['sql'] for query in self.captured_queries AssertionError: 0 != 1 : 0 queries executed, 1 expected ''' obj = Configuration(app_label='test', field_name='test5') obj.save() site.register_settings("test", { 'test5': forms.CharField( max_length=5, ), }) with self.assertNumQueries(1): value = Configuration.get_setting('test', 'test5') self.assertEqual(value, None, "Load a known setting value from database")
def test_manager_get_settings_new_initial(self): ''' FAIL: test_manager_get_settings_new_initial (tests.configuration.tests.ModelTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/travis/build/django-bmf/django-bmf/tests/configuration/tests.py", line 55, in test_manager_get_settings_new_initial self.assertEqual(value, 'test2', "Load a new setting value from database") AssertionError: None != 'test2' : Load a new setting value from database ''' site.register_settings("test", { 'test2': forms.CharField( max_length=5, initial='test2', ), }) value = Configuration.get_setting('test', 'test2') self.assertEqual(value, 'test2', "Load a new setting value from database")
def get_initial(self): self.initial.update({ 'asset_account': Configuration.get_setting('bmfcontrib_accounting', 'customer'), 'liability_account': Configuration.get_setting('bmfcontrib_accounting', 'supplier'), }) return super(BaseCreateView, self).get_initial()
def get_initial(self): self.initial.update({ 'product': Configuration.get_setting('bmfcontrib_product', 'default'), }) return super(EmployeeCreateView, self).get_initial()
def test_model_str(self): obj = Configuration(app_label='test', field_name='test7') obj.save() self.assertEqual('%s' % obj, 'test.test7', "Object string")
def test_model_delete(self): obj = Configuration(app_label='test', field_name='test6') obj.save() obj.delete()