Esempio n. 1
0
 def test_should_create_templates_options_context_processors_if_not_present(
         self):
     self.env = SettingWrapper(SettingsMock(TEMPLATES=[{'OPTIONS': {}}]))
     self.env.add_template_context_processors('foo')
     self.assertIn(
         'foo', self.env.settings.TEMPLATES[0].get('OPTIONS').get(
             'context_processors'))
Esempio n. 2
0
 def test_should_enfore_staticfiles_loaded_after_cubane_within_existing_list(
         self):
     self.env = SettingWrapper(
         SettingsMock(
             INSTALLED_APPS=['django.contrib.staticfiles', 'cubane']))
     self.env.add_apps()
     self.assertEqual(['cubane', 'django.contrib.staticfiles'],
                      self.env.settings.INSTALLED_APPS)
Esempio n. 3
0
 def setUp(self):
     self.env = SettingWrapper(
         SettingsMock(TEMPLATES=[{
             'OPTIONS': {
                 'context_processors': [
                     'foo',
                 ]
             }
         }]))
Esempio n. 4
0
class SettingsSettingWrapperAddTemplateContextProcessorsTestCase(
        CubaneTestCase):
    """
    cubane.settings.SettingWrapper.add_template_context_processors()
    """
    def setUp(self):
        self.env = SettingWrapper(
            SettingsMock(TEMPLATES=[{
                'OPTIONS': {
                    'context_processors': [
                        'foo',
                    ]
                }
            }]))

    def test_should_add_single_context_processor(self):
        self.env.add_template_context_processors('bar')
        self.assertEqual(['foo', 'bar'], self.env.settings.TEMPLATES[0].get(
            'OPTIONS').get('context_processors'))

    def test_should_add_multiple_context_processors(self):
        self.env.add_template_context_processors(['bar', 'test'])
        self.assertEqual(['foo', 'bar', 'test'],
                         self.env.settings.TEMPLATES[0].get('OPTIONS').get(
                             'context_processors'))

    def test_should_construct_structure_if_not_present(self):
        self.env = SettingWrapper(SettingsMock(BASE_PATH='/', DEBUG=True))
        self.env.add_template_context_processors('foo')
        self.assertIn(
            'foo', self.env.settings.TEMPLATES[0].get('OPTIONS').get(
                'context_processors'))

    def test_should_create_templates_options_if_not_present(self):
        self.env = SettingWrapper(SettingsMock(TEMPLATES=[{}]))
        self.env.add_template_context_processors('foo')
        self.assertIn(
            'foo', self.env.settings.TEMPLATES[0].get('OPTIONS').get(
                'context_processors'))

    def test_should_create_templates_options_context_processors_if_not_present(
            self):
        self.env = SettingWrapper(SettingsMock(TEMPLATES=[{'OPTIONS': {}}]))
        self.env.add_template_context_processors('foo')
        self.assertIn(
            'foo', self.env.settings.TEMPLATES[0].get('OPTIONS').get(
                'context_processors'))
Esempio n. 5
0
 def test_should_construct_structure_if_not_present(self):
     self.env = SettingWrapper(SettingsMock(BASE_PATH='/', DEBUG=True))
     self.env.add_template_context_processors('foo')
     self.assertIn(
         'foo', self.env.settings.TEMPLATES[0].get('OPTIONS').get(
             'context_processors'))
Esempio n. 6
0
 def setUp(self):
     self.env = SettingWrapper(SettingsMock(INSTALLED_APPS=['foo']))
Esempio n. 7
0
class SettingsSettingWrapperAddAppsTestCase(CubaneTestCase):
    """
    cubane.settings.SettingWrapper.add_apps()
    """
    def setUp(self):
        self.env = SettingWrapper(SettingsMock(INSTALLED_APPS=['foo']))

    def test_should_add_single_app(self):
        self.env.add_apps('bar')
        self.assertEqual(['foo', 'bar'], self.env.settings.INSTALLED_APPS)

    def test_should_add_multiple_apps(self):
        self.env.add_apps(['app1', 'app2'])
        self.assertEqual(['foo', 'app1', 'app2'],
                         self.env.settings.INSTALLED_APPS)

    def test_should_add_given_apps_to_settings_without_duplicates(self):
        self.env.add_apps(['foo', 'bar'])
        self.assertEqual(['foo', 'bar'], self.env.settings.INSTALLED_APPS)

    def test_should_add_staticfiles_without_dependencies_cubane(self):
        self.env.add_apps(['django.contrib.staticfiles'])
        self.assertEqual(['foo', 'django.contrib.staticfiles'],
                         self.env.settings.INSTALLED_APPS)

    def test_should_add_cubane_without_staticfiles(self):
        self.env.add_apps(['cubane'])
        self.assertEqual(['foo', 'cubane'], self.env.settings.INSTALLED_APPS)

    def test_should_add_staticfiles_after_cubane(self):
        self.env.add_apps(['cubane', 'django.contrib.staticfiles'])
        self.assertEqual(['foo', 'cubane', 'django.contrib.staticfiles'],
                         self.env.settings.INSTALLED_APPS)

    def test_should_enforce_staticfiles_loaded_after_cubane(self):
        self.env.add_apps(['django.contrib.staticfiles', 'cubane'])
        self.assertEqual(['foo', 'cubane', 'django.contrib.staticfiles'],
                         self.env.settings.INSTALLED_APPS)

    def test_should_enfore_staticfiles_loaded_after_cubane_within_existing_list(
            self):
        self.env = SettingWrapper(
            SettingsMock(
                INSTALLED_APPS=['django.contrib.staticfiles', 'cubane']))
        self.env.add_apps()
        self.assertEqual(['cubane', 'django.contrib.staticfiles'],
                         self.env.settings.INSTALLED_APPS)