Esempio n. 1
0
    def test_sqlite_verify_elements_rex(self):
        # check the full 118 using constraints built on just 92, but
        # also including regex constraints - and using constraints that
        # were built using pandas, so there are some type differences too.
        constraints_file = os.path.join(TESTDATA_DIR, 'elements92rex.tdda')
        result = verify_db_table('sqlite',
                                 self.db,
                                 'elements',
                                 constraints_file,
                                 testing=True)

        self.assertEqual(result.passes, 58)  # the original 57, minus the
        # type (and min and max) ones
        # on the Group field, which
        # the constraints (wrongly)
        # claim to be a real field,
        # rather than integer... but
        # also including three new
        # passing regex constraints

        self.assertEqual(result.failures, 20)  # the original 15, plus
        # the three additional failures
        # because of type mismatch
        # on the Group field, and
        # two failing regexps because
        # of having more elements.

        for field in result.fields.values():
            for name, value in field.items():
                self.assertEqual(type(value), bool)
Esempio n. 2
0
def verify_database_table_from_file(table,
                                    constraints_path,
                                    conn=None,
                                    dbtype=None,
                                    db=None,
                                    host=None,
                                    port=None,
                                    user=None,
                                    password=None,
                                    **kwargs):
    """
    Verify the given database table, against constraints in the .tdda
    file specified.

    Prints results to stdout.
    """
    (table, dbtype) = parse_table_name(table, dbtype)
    db = database_connection(table=table,
                             conn=conn,
                             dbtype=dbtype,
                             db=db,
                             host=host,
                             port=port,
                             user=user,
                             password=password)
    print(verify_db_table(dbtype, db, table, constraints_path, **kwargs))
Esempio n. 3
0
    def test_verify_elements_rex(self):
        # check the full 118 using constraints built on just 92, but
        # also including regex constraints - and using constraints that
        # were built using pandas, so there are some type differences too.
        constraints_file = os.path.join(TESTDATA_DIR, 'elements92rex.tdda')
        elements = self.dbh.resolve_table('elements')
        result = verify_db_table(self.dbh.dbtype, self.db, elements,
                                 constraints_file, testing=True)

        self.assertEqual(result.passes, 58)    # the original 57, minus the
                                               # type (and min and max) ones
                                               # on the Group field, which
                                               # the constraints (wrongly)
                                               # claim to be a real field,
                                               # rather than integer... but
                                               # also including three new
                                               # passing regex constraints

        self.assertEqual(result.failures, 20)  # the original 15, plus
                                               # the three additional failures
                                               # because of type mismatch
                                               # on the Group field, and
                                               # two failing regexps because
                                               # of having more elements.

        for field in result.fields.values():
            for name, value in field.items():
                self.assertEqual(type(value), bool)
Esempio n. 4
0
 def test_verify_elements(self):
     # check the full 118 using constraints built on just 92
     constraints_file = os.path.join(TESTDATA_DIR, 'elements92.tdda')
     elements = self.dbh.resolve_table('elements')
     result = verify_db_table(self.dbh.dbtype, self.db, elements,
                              constraints_file, testing=True)
     self.assertEqual(result.passes, 57)
     self.assertEqual(result.failures, 15)
Esempio n. 5
0
 def test_verify_elements(self):
     # check the full 118 using constraints built on just 92
     constraints_file = os.path.join(TESTDATA_DIR, 'elements92.tdda')
     elements = self.dbh.resolve_table('elements')
     result = verify_db_table(self.dbh.dbtype, self.db, elements,
                              constraints_file, testing=True)
     self.assertEqual(result.passes, 57)
     self.assertEqual(result.failures, 15)