def test_database_url_value(self):
     value = DatabaseURLValue()
     self.assertEqual(value.default, {})
     with env(DATABASE_URL='sqlite://'):
         self.assertEqual(value.setup('DATABASE_URL'), {
             'default': {
                 'ENGINE': 'django.db.backends.sqlite3',
                 'HOST': '',
                 'NAME': ':memory:',
                 'PASSWORD': '',
                 'PORT': '',
                 'USER': '',
             }})
示例#2
0
 def test_database_url_value(self):
     value = DatabaseURLValue()
     self.assertEqual(value.default, {})
     with env(DATABASE_URL='sqlite://'):
         self.assertEqual(value.setup('DATABASE_URL'), {
             'default': {
                 'ENGINE': 'django.db.backends.sqlite3',
                 'HOST': '',
                 'NAME': ':memory:',
                 'PASSWORD': '',
                 'PORT': '',
                 'USER': '',
             }})
示例#3
0
    def test_database_url_additional_args(self):

        def mock_database_url_caster(self, url, engine=None):
            return { 'URL': url, 'ENGINE': engine }

        with patch('configurations.values.DatabaseURLValue.caster', mock_database_url_caster):
            value = DatabaseURLValue(engine='django_mysqlpool.backends.mysqlpool')
            with env(DATABASE_URL='sqlite://'):
                self.assertEqual(value.setup('DATABASE_URL'), {
                    'default': {
                        'URL': 'sqlite://',
                        'ENGINE': 'django_mysqlpool.backends.mysqlpool'
                    }
                })
示例#4
0
    def test_database_url_additional_args(self):
        def mock_database_url_caster(self, url, engine=None):
            return {'URL': url, 'ENGINE': engine}

        with patch('configurations.values.DatabaseURLValue.caster',
                   mock_database_url_caster):
            value = DatabaseURLValue(
                engine='django_mysqlpool.backends.mysqlpool')
            with env(DATABASE_URL='sqlite://'):
                self.assertEqual(
                    value.setup('DATABASE_URL'), {
                        'default': {
                            'URL': 'sqlite://',
                            'ENGINE': 'django_mysqlpool.backends.mysqlpool'
                        }
                    })
示例#5
0
 def test_database_url_value(self):
     value = DatabaseURLValue()
     self.assertEqual(value.default, {})
     with env(DATABASE_URL="sqlite://"):
         self.assertEqual(
             value.setup("DATABASE_URL"),
             {
                 "default": {
                     "ENGINE": "django.db.backends.sqlite3",
                     "HOST": "",
                     "NAME": ":memory:",
                     "PASSWORD": "",
                     "PORT": "",
                     "USER": "",
                 }
             },
         )