Beispiel #1
0
    def test_key_values(self):

        LOG.debug('Test key values')

        # Test setup
        host_name = 'host123456'
        host_transformer = HostTransformer(self.transformers)

        # Test action
        observed_key_fields = host_transformer._key_values(
            NOVA_HOST_DATASOURCE,
            host_name)

        # Test assertions
        self.assertEqual(EntityCategory.RESOURCE, observed_key_fields[0])
        self.assertEqual(NOVA_HOST_DATASOURCE, observed_key_fields[1])
        self.assertEqual(host_name, observed_key_fields[2])
Beispiel #2
0
    def test_create_placeholder_vertex(self):
        LOG.debug('Nova host transformer test: Test create placeholder vertex')

        # Test setup
        host_name = 'host123'
        timestamp = datetime.datetime.utcnow()
        host_transformer = HostTransformer(self.transformers)

        # Test action
        properties = {
            VertexProperties.ID: host_name,
            VertexProperties.TYPE: NOVA_HOST_DATASOURCE,
            VertexProperties.SAMPLE_TIMESTAMP: timestamp
        }
        placeholder = host_transformer.create_placeholder_vertex(**properties)

        # Test assertions
        observed_id_values = placeholder.vertex_id.split(
            TransformerBase.KEY_SEPARATOR)
        expected_id_values = host_transformer._key_values(
            NOVA_HOST_DATASOURCE,
            host_name)
        self.assertEqual(tuple(observed_id_values), expected_id_values)

        observed_time = placeholder.get(VertexProperties.SAMPLE_TIMESTAMP)
        self.assertEqual(observed_time, timestamp)

        observed_subtype = placeholder.get(VertexProperties.TYPE)
        self.assertEqual(observed_subtype, NOVA_HOST_DATASOURCE)

        observed_entity_id = placeholder.get(VertexProperties.ID)
        self.assertEqual(observed_entity_id, host_name)

        observed_category = placeholder.get(VertexProperties.CATEGORY)
        self.assertEqual(observed_category, EntityCategory.RESOURCE)

        is_placeholder = placeholder.get(VertexProperties.IS_PLACEHOLDER)
        self.assertEqual(is_placeholder, True)