Exemplo n.º 1
0
 def test_get_db_name_by_config_name(self):
     with tmp_configuration(db_name='anyblok',
                            db_driver_name='postgres',
                            db_host='localhost',
                            db_user_name=None,
                            db_password=None,
                            db_port=None):
         assert get_db_name() == 'anyblok'
Exemplo n.º 2
0
 def test_preload_databases(self):
     db_name = Configuration.get('db_name')
     with tmp_configuration(db_names=[db_name]):
         with LogCapture('anyblok_pyramid.common', level=INFO) as handler:
             preload_databases()
             messages = handler.get_info_messages()
             assert messages
             assert 'The database %r is preloaded' % db_name in messages
Exemplo n.º 3
0
 def test_preload_unexisting_databases(self):
     db_name = 'wrong_db_name'
     with tmp_configuration(db_names=[db_name]):
         with LogCapture('anyblok_pyramid.common',
                         level=WARNING) as handler:
             preload_databases()
             messages = handler.get_warning_messages()
             assert messages
             assert 'The database %r does not exist' % db_name in messages
Exemplo n.º 4
0
 def test_get_url_without_drivername(self):
     with tmp_configuration(db_name=None,
                            db_driver_name=None,
                            db_host=None,
                            db_user_name=None,
                            db_password=None,
                            db_port=None):
         with pytest.raises(ConfigurationException):
             get_url()
Exemplo n.º 5
0
 def test_get_url2(self):
     with tmp_configuration(db_name='anyblok',
                            db_driver_name='postgres',
                            db_host='localhost',
                            db_user_name=None,
                            db_password=None,
                            db_port=None):
         url = get_url(db_name='anyblok2')
         self.check_url(url, 'postgres://localhost/anyblok2')
Exemplo n.º 6
0
 def test_get_url5(self):
     with tmp_configuration(db_url='postgres:///anyblok',
                            db_name='anyblok2',
                            db_driver_name=None,
                            db_host=None,
                            db_user_name='jssuzanne',
                            db_password='******',
                            db_port=None):
         url = get_url(db_name='anyblok3')
         self.check_url(url, 'postgres://*****:*****@/anyblok3')
Exemplo n.º 7
0
 def test_get_url3(self):
     with tmp_configuration(db_url='postgres:///anyblok',
                            db_name=None,
                            db_driver_name=None,
                            db_host=None,
                            db_user_name=None,
                            db_password=None,
                            db_port=None):
         url = get_url()
         self.check_url(url, 'postgres:///anyblok')
Exemplo n.º 8
0
    def test_datetime_with_default_global_timezone_str(self, dt_column_type):
        import datetime
        import pytz

        timezone = pytz.timezone('Asia/Tokyo')
        now = datetime.datetime.now()
        with tmp_configuration(default_timezone='Asia/Tokyo'):
            registry = self.init_registry(simple_column,
                                          ColumnType=dt_column_type)

        field = registry.loaded_namespaces_first_step['Model.Test']['col']
        assert field.default_timezone is timezone

        test = registry.Test.insert(col=now)
        assert test.col.tzinfo.zone is timezone.zone
Exemplo n.º 9
0
 def test_check_security_ko(self, rollback_registry):
     request = MockRequest('192.68.1.1')
     with tmp_configuration(furetui_authorized_networks='192.168.1.1/32'):
         rollback_registry.FuretUI.define_authorized_ips()
         acl = rollback_registry.FuretUI.check_security(request)
         assert acl is False
Exemplo n.º 10
0
 def test_define_authorized_ips_without_mask(self, rollback_registry):
     with tmp_configuration(furetui_authorized_networks='192.168.1.1'):
         rollback_registry.FuretUI.define_authorized_ips()