コード例 #1
0
def test_db_create_POST(testing_wapp):
    with testing_wapp('core') as ctx:
        req = ctx.request(post={
            'admin_user': '******',
            'admin_password': '******'
        })
        with ctx.redirect('/_/setup'):
            setup.dbCreate(req=req)
コード例 #2
0
def test_db_create(testing_wapp):
    with testing_wapp('core') as ctx:
        d = setup.dbCreate()
        assert isinstance(d, dict)
        assert d == {
            'db': {
                'config': '',
                'driver': 'sqlite',
                'name': ':memory:core_testdb'
            }
        }
コード例 #3
0
def test_database_error(testing_wapp):
    with testing_wapp('core', db=True) as ctx:
        req = ctx.request(post={
            'admin_user': '******',
            'admin_password': '******'
        })
        _dbconn = setup._dbconn
        try:
            setup._dbconn = Mock()
            setup._dbconn.side_effect = db.DatabaseError('testing db error')
            d = setup.dbCreate(req=req)
            err = d['error']
            assert err == 'testing db error'
        finally:
            del setup._dbconn
            setup._dbconn = _dbconn
コード例 #4
0
def test_db_integrity_error(testing_wapp):
    with testing_wapp('core') as ctx:
        req = ctx.request(post={
            'admin_user': '******',
            'admin_password': '******'
        })
        db_create = setup.db.create
        try:
            setup.db.create = Mock()
            setup.db.create.side_effect = db.IntegrityError(
                'testing integrity error')
            d = setup.dbCreate(req=req)
            err = d['error']
            assert err == 'testing integrity error'
        finally:
            del setup.db.create
            setup.db.create = db_create
コード例 #5
0
def test_db_is_created(testing_wapp):
    with testing_wapp('core', db=True) as ctx:
        d = setup.dbCreate()
        assert isinstance(d, dict)
        err = d['error']
        assert err == 'database already created?'