Example #1
0
 def test(self):
     location = self.schemata
     # Keep track of lack of failures.
     failed = False
     # Get the maximum schema version.
     final_version = max(
         schevo.schema.latest_version(location), self.max_version)
     # For schema version N from 2 to maximum,
     for N in xrange(2, final_version + 1):
         # Read schema version N.
         schema_N = schevo.schema.read(location, N)
         # Create a database directly at version N.
         fp_direct = StringIO()
         db_direct = database.create(
             filename=None,
             backend_name='schevo.store',
             backend_args=dict(fp=fp_direct, cache_size=100000),
             schema_source=schema_N,
             schema_version=N,
             )
         # Read schema version N - 1.
         schema_N1 = schevo.schema.read(location, N - 1)
         # Create a database at version N - 1.
         fp_evolved = StringIO()
         db_evolved = database.create(
             filename=None,
             backend_name='schevo.store',
             backend_args=dict(fp=fp_evolved, cache_size=100000),
             schema_source=schema_N1,
             schema_version=N - 1,
             )
         # Evolve database to version N.
         database.evolve(db_evolved, schema_N, N)
         # Compare the databases.
         is_equivalent = database.equivalent(db_direct, db_evolved)
         # If failure,
         if not is_equivalent:
             if self.expected_failure:
                 # If failure expected, keep track of failure.
                 failed = True
             else:
                 # If failure not expected, raise an exception.
                 raise Exception(
                     'Database created directly at version %i is not '
                     'the same as database created at version %i then '
                     'evolved to version %i.'
                     % (N, N - 1, N)
                     )
         db_direct.close()
         db_evolved.close()
     # If failure expected, but no failures,
     if self.expected_failure and not failed:
         # Raise an exception.
         raise Exception(
             'Expected databases to be unequal at some point, but '
             'they are all functionally equivalent.'
             )
Example #2
0
 def test(self):
     self.open('2')
     assert not equivalent(db, db2, require_identical_schema_source=False)
Example #3
0
 def test_identical_schema_source_required(self):
     self.open('2')
     assert not equivalent(db, db2)