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
        placeholder = host_transformer.create_placeholder_vertex(
            host_name,
            timestamp
        )

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

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

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

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

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

        is_placeholder = placeholder.get(VertexProperties.IS_PLACEHOLDER)
        self.assertEqual(is_placeholder, True)
    def test_extract_action_type(self):
        LOG.debug('Test extract action type')

        # Test setup
        spec_list = mock_sync.simple_host_generators(
            zone_num=1,
            host_num=1,
            snapshot_events=1,
            snap_vals={'sync_mode': SyncMode.SNAPSHOT})

        hosts_events = mock_sync.generate_random_events_list(spec_list)
        host_transformer = HostTransformer(self.transformers)

        # Test action
        action = host_transformer._extract_action_type(hosts_events[0])

        # Test assertion
        self.assertEqual(EventAction.UPDATE, action)

        # Test setup
        spec_list = mock_sync.simple_host_generators(
            zone_num=1,
            host_num=1,
            snapshot_events=1,
            snap_vals={'sync_mode': SyncMode.INIT_SNAPSHOT})
        hosts_events = mock_sync.generate_random_events_list(spec_list)
        host_transformer = HostTransformer(self.transformers)

        # Test action
        action = host_transformer._extract_action_type(hosts_events[0])

        # Test assertions
        self.assertEqual(EventAction.CREATE, action)
    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(
            [host_name]
        )

        # Test assertions
        self.assertEqual(EntityTypes.RESOURCE, observed_key_fields[0])
        self.assertEqual(
            host_transformer.HOST_TYPE,
            observed_key_fields[1]
        )
        self.assertEqual(host_name, observed_key_fields[2])