Browse Source

fix tests

* fix the path to config file
* missing test base class
* changing keys while iterating on a dict

Change-Id: I526ab6c5f4cdd603107b0e89eecd8b01e68a94b9
tags/6.0.0
Eyal 4 months ago
parent
commit
8122f24ebe
4 changed files with 14 additions and 9 deletions
  1. +7
    -4
      vitrage/tests/unit/datasources/kubernetes/test_kubernetes_transformer.py
  2. +2
    -2
      vitrage/tests/unit/evaluator/test_template_loader.py
  3. +3
    -2
      vitrage/tests/unit/snmp_parsing/test_snmp_parsing.py
  4. +2
    -1
      vitrage/tests/unit/storage/test_migrations.py

+ 7
- 4
vitrage/tests/unit/datasources/kubernetes/test_kubernetes_transformer.py View File

@@ -34,6 +34,7 @@ from vitrage.datasources import transformer_base as tbase
from vitrage.datasources.transformer_base import TransformerBase
from vitrage.tests import base
from vitrage.tests.mocks import mock_driver as mock_sync
from vitrage.tests.mocks import utils

LOG = logging.getLogger(__name__)

@@ -46,8 +47,8 @@ class KubernetesTransformerTest(base.BaseTest):
cfg.StrOpt(DSOpts.UPDATE_METHOD,
default=UpdateMethod.PULL),
cfg.StrOpt(DSOpts.CONFIG_FILE,
default='/opt/stack/vitrage/vitrage/tests/resources/'
'kubernetes/kubernetes_config.yaml'),
default=utils.get_resources_dir() +
'/kubernetes/kubernetes_config.yaml'),
]

# noinspection PyAttributeOutsideInit,PyPep8Naming
@@ -55,13 +56,15 @@ class KubernetesTransformerTest(base.BaseTest):
def setUpClass(cls):
super(KubernetesTransformerTest, cls).setUpClass()
cls.transformers = {}
cls.conf = cfg.ConfigOpts()
cls.conf.register_opts(cls.OPTS, group=KUBERNETES_DATASOURCE)
cls.transformers[KUBERNETES_DATASOURCE] = KubernetesTransformer(
cls.transformers)
cls.transformers[NOVA_INSTANCE_DATASOURCE] = \
InstanceTransformer(cls.transformers)

def setUp(self):
super(KubernetesTransformerTest, self).setUp()
self.conf_reregister_opts(self.OPTS, group=KUBERNETES_DATASOURCE)

def test_snapshot_event_transform(self):
LOG.debug('Test tactual transform action for '
'snapshot and snapshot init events')


+ 2
- 2
vitrage/tests/unit/evaluator/test_template_loader.py View File

@@ -74,7 +74,7 @@ class TemplateLoaderTest(base.BaseTest):

# Assertions
for definition in definitions[TFields.ENTITIES]:
for key, value in definition['entity'].items():
for key, value in list(definition['entity'].items()):
new_key = PropsConverter.PROPS_CONVERSION[key] \
if key in PropsConverter.PROPS_CONVERSION else key
del definition['entity'][key]
@@ -173,7 +173,7 @@ class TemplateLoaderTest(base.BaseTest):

# Assertions
for definition in definitions[TFields.ENTITIES]:
for key, value in definition['entity'].items():
for key, value in list(definition['entity'].items()):
new_key = PropsConverter.PROPS_CONVERSION[key] \
if key in PropsConverter.PROPS_CONVERSION else key
del definition['entity'][key]


+ 3
- 2
vitrage/tests/unit/snmp_parsing/test_snmp_parsing.py View File

@@ -22,6 +22,7 @@ from pysnmp.proto.rfc1902 import TimeTicks

from vitrage.snmp_parsing.service import SnmpParsingService
from vitrage.tests import base
from vitrage.tests.mocks import utils


BINDS_REPORTED = [
@@ -112,8 +113,8 @@ class TestSnmpParsing(base.BaseTest):
super(TestSnmpParsing, self).setUp()
self.cfg_fixture.config(
group='snmp_parsing',
oid_mapping='vitrage/tests/resources/snmp_parsing/'
'snmp_parsing_conf.yaml')
oid_mapping=utils.get_resources_dir() +
'/snmp_parsing/snmp_parsing_conf.yaml')

def test_convert_binds_to_dict(self):
parsing_service = SnmpParsingService(1)


+ 2
- 1
vitrage/tests/unit/storage/test_migrations.py View File

@@ -93,7 +93,8 @@ class MigrationCheckersMixin(object):

class TestMigrationsMySQL(MigrationCheckersMixin,
WalkWersionsMixin,
test_fixtures.OpportunisticDBTestMixin):
test_fixtures.OpportunisticDBTestMixin,
test_base.BaseTestCase):
FIXTURE = test_fixtures.MySQLOpportunisticFixture




Loading…
Cancel
Save