Exemplo n.º 1
0
def use_mock(*args):
    kw_args = {}

    for service in args:
        key = 'RESTCLIENTS_%s_DAO_CLASS' % service.service_name().upper()

        kw_args[key] = 'Mock'

    return override_settings(**kw_args)
Exemplo n.º 2
0
    def test_is_django_mysql(self):
        with override_settings(DATABASES=None):
            self.assertFalse(is_django_mysql())

        with override_settings(DATABASES='mysql'):
            self.assertFalse(is_django_mysql())

        with override_settings(DATABASES={
                'default': {
                    'ENGINE': 'django.db.backends.sqlite3'
                }
        }):
            self.assertFalse(is_django_mysql())

        with override_settings(
                DATABASES={'default': {
                    'ENGINE': 'django.db.backends.mysql'
                }}):
            self.assertTrue(is_django_mysql())
Exemplo n.º 3
0
    def test_context(self):
        use_configparser_backend(config_path, "Section1")
        self.assertTrue(settings.DEBUG)

        with self.assertRaises(Exception):
            settings.OTHER

        with override_settings(DEBUG="What!", OTHER="Also"):
            debug = settings.DEBUG
            other = settings.OTHER

        self.assertEquals(debug, "What!")
        self.assertEquals(other, "Also")

        self.assertTrue(settings.DEBUG)

        with self.assertRaises(Exception):
            settings.OTHER
Exemplo n.º 4
0
    def test_update_login(self, mock_update):
        canvas = Users()

        user_id = 188885
        logins = canvas.get_user_logins(user_id)

        login = logins[0]
        login.unique_id = "testid99new"
        login.sis_user_id = ""

        canvas.update_user_login(login, account_id=12345)
        mock_update.assert_called_with(
            '/api/v1/accounts/12345/logins/100',
            {'login': {'sis_user_id': '', 'unique_id': 'testid99new'}})

        with override_settings(RESTCLIENTS_CANVAS_ACCOUNT_ID=None):
            canvas = Users()
            self.assertRaises(
                MissingAccountID, canvas.update_user_login, login)
Exemplo n.º 5
0
 def test_custom_headers(self):
     self.assertFalse(R25_DAO()._custom_headers('GET', '/', {}, None))
     with override_settings(RESTCLIENTS_R25_BASIC_AUTH='b64here'):
         self.assertEquals(R25_DAO()._custom_headers('GET', '/', {}, None),
                           {'Authorization': 'Basic b64here'})
Exemplo n.º 6
0
from commonconf import override_settings


fdao_gws_override = override_settings(RESTCLIENTS_GWS_DAO_CLASS='Mock')
Exemplo n.º 7
0
# Copyright 2022 UW-IT, University of Washington
# SPDX-License-Identifier: Apache-2.0

from commonconf import override_settings


fdao_spotseeker_override = override_settings(
    RESTCLIENTS_SPOTSEEKER_DAO_CLASS='Mock')
Exemplo n.º 8
0
# Copyright 2021 UW-IT, University of Washington
# SPDX-License-Identifier: Apache-2.0

from commonconf import override_settings

fdao_canvas_override = override_settings(RESTCLIENTS_CANVAS_DAO_CLASS='Mock',
                                         RESTCLIENTS_CANVAS_ACCOUNT_ID=12345,
                                         CANVAS_REPORT_POLLING_INTERVAL=0.001)
Exemplo n.º 9
0
# Copyright 2021 UW-IT, University of Washington
# SPDX-License-Identifier: Apache-2.0

from commonconf import override_settings
from dateutil.parser import parse


fdao_bridge_override = override_settings(RESTCLIENTS_BRIDGE_DAO_CLASS='Mock')
ldao_bridge_override = override_settings(RESTCLIENTS_BRIDGE_DAO_CLASS='Live')


def parse_date(date_str):
    if date_str is not None:
        return parse(date_str)
    return None
Exemplo n.º 10
0
from commonconf import override_settings

fdao_adsel_override = override_settings(RESTCLIENTS_ADSEL_DAO_CLASS='Mock')