Exemplo n.º 1
0
    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")
Exemplo n.º 2
0
 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()
Exemplo n.º 3
0
 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
Exemplo n.º 4
0
 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
Exemplo n.º 5
0
 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")
Exemplo n.º 6
0
 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")
Exemplo n.º 7
0
 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()
Exemplo n.º 8
0
 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()
Exemplo n.º 9
0
 def get_initial(self):
     self.initial.update({
         'product':
         Configuration.get_setting('bmfcontrib_product', 'default'),
     })
     return super(EmployeeCreateView, self).get_initial()
Exemplo n.º 10
0
 def get_initial(self):
     self.initial.update({
         'product': Configuration.get_setting('bmfcontrib_product', 'default'),
     })
     return super(EmployeeCreateView, self).get_initial()