Ejemplo n.º 1
0
def test_schema_upgrade_on_open():
    for old_version in USABLE_VERSIONS[:-1]:
        with tempfile.NamedTemporaryFile(prefix='bayeslite') as f:
            try:
                with bayesdb_open(pathname=f.name,
                                  version=old_version,
                                  compatible=True) as bdb:
                    for needs_version in USABLE_VERSIONS:
                        case = 'has%s needs%s' % (old_version, needs_version)
                        if needs_version <= old_version:
                            bayesdb_schema_required(bdb, needs_version,
                                                    case + ' ok')
                        else:
                            try:
                                with pytest.raises(BayesDBException):
                                    bayesdb_schema_required(
                                        bdb, needs_version, case + ' fail')
                            except:
                                print case, "should fail"
                                raise
                    test_core.t1_schema(bdb)
                    test_core.t1_data(bdb)
                with bayesdb_open(pathname=f.name, compatible=False) as bdb:
                    for needs_version in USABLE_VERSIONS:
                        bayesdb_schema_required(
                            bdb, needs_version,
                            'needs%s after upgrade' % (needs_version, ))
                    with pytest.raises(BayesDBException):
                        # Nobody'll ever bump the schema version this many
                        # times, right?
                        bayesdb_schema_required(bdb, 1000000, 'a gazillion')
            except:
Ejemplo n.º 2
0
def test_schema_upgrade_on_open():
    for old_version in USABLE_VERSIONS[:-1]:
        with tempfile.NamedTemporaryFile(prefix='bayeslite') as f:
            try:
                with bayesdb_open(pathname=f.name,
                                  version=old_version, compatible=True) as bdb:
                    for needs_version in USABLE_VERSIONS:
                        case = 'has%s needs%s' % (old_version, needs_version)
                        if needs_version <= old_version:
                            bayesdb_schema_required(
                                bdb, needs_version, case + ' ok')
                        else:
                            try:
                                with pytest.raises(BayesDBException):
                                    bayesdb_schema_required(
                                        bdb, needs_version, case + ' fail')
                            except:
                                print case, "should fail"
                                raise
                    test_core.t1_schema(bdb)
                    test_core.t1_data(bdb)
                with bayesdb_open(pathname=f.name, compatible=False) as bdb:
                    for needs_version in USABLE_VERSIONS:
                        bayesdb_schema_required(
                            bdb, needs_version,
                            'needs%s after upgrade' % (needs_version,))
                    with pytest.raises(BayesDBException):
                        # Nobody'll ever bump the schema version this many
                        # times, right?
                        bayesdb_schema_required(bdb, 1000000, 'a gazillion')
            except:
                print "old_version =", old_version, "file =", f.name
                raise
Ejemplo n.º 3
0
def test_schema_upgrade():
    with bayesdb_open(version=6) as bdb:
        bayesdb_schema_required(bdb, 6, 'test pre-upgrade 6')
        with pytest.raises(BayesDBException):
            bayesdb_schema_required(bdb, 7, 'test pre-upgrade 7')
        test_core.t1_schema(bdb)
        test_core.t1_data(bdb)
        bayesdb_upgrade_schema(bdb)
        bayesdb_schema_required(bdb, 6, 'test post-upgrade 6')
        bayesdb_schema_required(bdb, 7, 'test post-upgrade 7')
        with pytest.raises(BayesDBException):
            # Nobody'll ever bump the schema version this many times,
            # right?
            bayesdb_schema_required(bdb, 1000000, 'test a gazillion')
Ejemplo n.º 4
0
def test_schema_upgrade():
    with bayesdb_open(version=6) as bdb:
        bayesdb_schema_required(bdb, 6, 'test pre-upgrade 6')
        with pytest.raises(BayesDBException):
            bayesdb_schema_required(bdb, 7, 'test pre-upgrade 7')
        test_core.t1_schema(bdb)
        test_core.t1_data(bdb)
        bayesdb_upgrade_schema(bdb)
        bayesdb_schema_required(bdb, 6, 'test post-upgrade 6')
        bayesdb_schema_required(bdb, 7, 'test post-upgrade 7')
        with pytest.raises(BayesDBException):
            # Nobody'll ever bump the schema version this many times,
            # right?
            bayesdb_schema_required(bdb, 1000000, 'test a gazillion')