コード例 #1
0
    def _skip_if_not_postgres(self):
        # Note: pytest.mark.skipif cannot be used at the class level,
        # since this could have the side-effect of also disabling the sqlite
        # tests.
        #
        # It appears that adding a skip to this class causes
        # all other test classes using the DatabaseTestBase base class to be
        # skipped too.

        if not got_postgresql():
            pytest.skip('Needs postgresql')
コード例 #2
0
import pytest
import tempfile
import yaml

from abridger.exc import RelationIntegrityError
from abridger.extraction_model import Relation
from abridger.schema import PostgresqlSchema
from test.conftest import got_postgresql


@pytest.mark.skipif(not got_postgresql(), reason='Needs postgresql')
class TestPostgresqlSchema(object):
    test_relations_stmts = '''
        CREATE TABLE test1 (
            id SERIAL PRIMARY KEY,
            alt_id SERIAL UNIQUE,
            alt_id1 SERIAL,
            alt_id2 SERIAL,
            UNIQUE(alt_id1, alt_id2)
        );

        CREATE TABLE test2 (
            id SERIAL PRIMARY KEY,
            fk1 INTEGER REFERENCES test1,
            fk2 INTEGER CONSTRAINT test_constraint REFERENCES test1,
            fk3 INTEGER REFERENCES test1(alt_id),
            fk4 INTEGER,
            fk5 INTEGER,
            FOREIGN KEY (fk4, fk5) REFERENCES test1(alt_id1, alt_id2)
        );
    '''
コード例 #3
0
import os
import pytest
import re
import subprocess

from abridger.abridge_db import main
from abridger.database.sqlite import SqliteDatabase
from test.abridge_db_test_utils import TestAbridgeDbBase
from test.conftest import got_postgresql
from test.fixtures.postgresql import make_postgresql_database

postgresql_proc2 = factories.postgresql_proc(port=5434)
postgresql2 = factories.postgresql('postgresql_proc2')


@pytest.mark.skipif(not got_postgresql(), reason='Needs postgresql')
class TestAbridgeDbForPostgresql(TestAbridgeDbBase):
    def setup_method(self, method):
        self.src_database = None
        self.dst_database = None

    def teardown_method(self, method):
        # Belt and braces in case something unexpected fails
        if self.src_database is not None:
            self.src_database.disconnect
        if self.dst_database is not None:
            self.dst_database.disconnect

    def prepare_src(self, postgresql):
        self.src_database = make_postgresql_database(postgresql)
        self.src_conn = self.src_database.connection