From b8d281a303ca12440aebb55895ebb192d25cecf8 Mon Sep 17 00:00:00 2001 From: AKamyshnikova Date: Wed, 16 Dec 2015 15:32:45 +0300 Subject: [PATCH] Fix comparison of Variant and other type in test_model_sync Tests TestModelsMigrations failed on comparation Variant type and BigInteger after alembic 0.8.4 release. Current change corrected compare_type for such case. Closes-bug: #1526675 Co-Authored-By: Ihar Hrachyshka Change-Id: I7ae7aaf053a81f487d9ec14859700806fa4f9017 --- .../tests/functional/db/test_migrations.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/neutron/tests/functional/db/test_migrations.py b/neutron/tests/functional/db/test_migrations.py index 80a011737a9..76489b71f93 100644 --- a/neutron/tests/functional/db/test_migrations.py +++ b/neutron/tests/functional/db/test_migrations.py @@ -23,6 +23,7 @@ from oslo_db.sqlalchemy import test_base from oslo_db.sqlalchemy import test_migrations import sqlalchemy from sqlalchemy import event +import sqlalchemy.types as types from neutron.api.v2 import attributes as attr import neutron.db.migration as migration_help @@ -134,6 +135,24 @@ class _TestModelsMigrations(test_migrations.ModelsMigrationsSync): def filter_metadata_diff(self, diff): return list(filter(self.remove_unrelated_errors, diff)) + # TODO(akamyshikova): remove this method as soon as comparison with Variant + # will be implemented in oslo.db or alembic + def compare_type(self, ctxt, insp_col, meta_col, insp_type, meta_type): + if isinstance(meta_type, types.Variant): + orig_type = meta_col.type + meta_col.type = meta_type.impl + try: + return self.compare_type(ctxt, insp_col, meta_col, insp_type, + meta_type.impl) + finally: + meta_col.type = orig_type + else: + ret = super(_TestModelsMigrations, self).compare_type( + ctxt, insp_col, meta_col, insp_type, meta_type) + if ret is not None: + return ret + return ctxt.impl.compare_type(insp_col, meta_col) + # Remove some difference that are not mistakes just specific of # dialects, etc def remove_unrelated_errors(self, element):