Beispiel #1
0
    def test__create_metadata_dictionary(self):
        expected_key = ("ironic_node_%s" % self.node.uuid)
        expected = {
            expected_key: {
                'instance_uuid': self.node.instance_uuid,
                'last_seen': 'faked-time',
                'last_action': 'meow'
            }
        }

        result = cinder._create_metadata_dictionary(self.node, 'meow')
        self.assertIsInstance(result[expected_key]['last_seen'], str)
        result[expected_key]['last_seen'] = 'faked-time'
        self.assertEqual(expected, result)
    def test__create_metadata_dictionary(self, mock_datetime):
        fake_time = '2017-06-05T00:33:26.574676'
        mock_utcnow = mock.Mock()
        mock_datetime.utcnow.return_value = mock_utcnow
        mock_utcnow.isoformat.return_value = fake_time
        expected_key = ("ironic_node_%s" % self.node.uuid)
        expected_data = {
            'instance_uuid': self.node.instance_uuid,
            'last_seen': fake_time,
            'last_action': 'meow'
        }

        result = cinder._create_metadata_dictionary(self.node, 'meow')
        data = json.loads(result[expected_key])
        self.assertEqual(expected_data, data)
Beispiel #3
0
    def test__create_metadata_dictionary(self, mock_datetime):
        fake_time = '2017-06-05T00:33:26.574676'
        mock_utcnow = mock.Mock()
        mock_datetime.utcnow.return_value = mock_utcnow
        mock_utcnow.isoformat.return_value = fake_time
        expected_key = ("ironic_node_%s" % self.node.uuid)
        expected_data = {
            'instance_uuid': self.node.instance_uuid,
            'last_seen': fake_time,
            'last_action': 'meow'
        }

        result = cinder._create_metadata_dictionary(self.node, 'meow')
        data = json.loads(result[expected_key])
        self.assertEqual(expected_data, data)
Beispiel #4
0
    def test__create_metadata_dictionary(self):
        expected_key = ("ironic_node_%s" % self.node.uuid)
        expected = {
            expected_key: {
                'instance_uuid': self.node.instance_uuid,
                'last_seen': 'faked-time',
                'last_action': 'meow'
            }
        }

        result = cinder._create_metadata_dictionary(self.node, 'meow')
        self.maxDiff = None
        # Since datetime is an internal, we can't exactly mock it.
        # We can however verify it's presence, and replace it.
        self.assertIsInstance(result[expected_key]['last_seen'], str)
        result[expected_key]['last_seen'] = 'faked-time'
        self.assertDictEqual(expected, result)