Пример #1
0
    def test_parse_live_resource_data(self):
        t = template_format.parse(wp_template)
        self.parse_stack(t)

        queue = self.stack['MyQueue2']
        fake_q = FakeQueue(queue.physical_resource_name(), auto_create=False)
        self.fc.queue.return_value = fake_q
        queue_metadata = queue.properties.get('metadata')
        fake_q.metadata.return_value = queue_metadata
        scheduler.TaskRunner(queue.create)()
        fake_q.metadata.assert_called_with(new_meta=queue_metadata)
        self.fc.queue.assert_called_once_with(queue.physical_resource_name(),
                                              auto_create=False)
        self.assertEqual(
            {
                'metadata': {
                    "key1": {
                        "key2": "value",
                        "key3": [1, 2]
                    }
                },
                'name': queue.resource_id
            },
            queue.parse_live_resource_data(queue.properties,
                                           queue._show_resource()))
        fake_q.metadata.assert_called_with()
Пример #2
0
    def test_parse_live_resource_data(self):
        t = template_format.parse(wp_template)
        self.parse_stack(t)

        queue = self.stack['MyQueue2']
        self.m.StubOutWithMock(queue, 'client')
        queue.client().MultipleTimes().AndReturn(self.fc)

        fake_q = FakeQueue(queue.physical_resource_name(), auto_create=False)
        self.m.StubOutWithMock(self.fc, 'queue')
        self.fc.queue(queue.physical_resource_name(),
                      auto_create=False).AndReturn(fake_q)
        self.m.StubOutWithMock(fake_q, 'metadata')
        fake_q.metadata(new_meta=queue.properties.get('metadata'))
        self.fc.queue(queue.physical_resource_name(),
                      auto_create=False).AndReturn(fake_q)
        fake_q.metadata().AndReturn(
            {"key1": {"key2": "value", "key3": [1, 2]}})
        self.m.ReplayAll()

        scheduler.TaskRunner(queue.create)()
        self.assertEqual(
            {'metadata': {"key1": {"key2": "value", "key3": [1, 2]}},
             'name': queue.resource_id},
            queue.parse_live_resource_data(queue.properties,
                                           queue._show_resource()))

        self.m.VerifyAll()
Пример #3
0
    def test_parse_live_resource_data(self):
        t = template_format.parse(wp_template)
        self.parse_stack(t)

        queue = self.stack['MyQueue2']
        self.m.StubOutWithMock(queue, 'client')
        queue.client().MultipleTimes().AndReturn(self.fc)

        fake_q = FakeQueue(queue.physical_resource_name(), auto_create=False)
        self.m.StubOutWithMock(self.fc, 'queue')
        self.fc.queue(queue.physical_resource_name(),
                      auto_create=False).AndReturn(fake_q)
        self.m.StubOutWithMock(fake_q, 'metadata')
        fake_q.metadata(new_meta=queue.properties.get('metadata'))
        self.fc.queue(queue.physical_resource_name(),
                      auto_create=False).AndReturn(fake_q)
        fake_q.metadata().AndReturn(
            {"key1": {"key2": "value", "key3": [1, 2]}})
        self.m.ReplayAll()

        scheduler.TaskRunner(queue.create)()
        self.assertEqual(
            {'metadata': {"key1": {"key2": "value", "key3": [1, 2]}},
             'name': queue.resource_id},
            queue.parse_live_resource_data(queue.properties,
                                           queue._show_resource()))

        self.m.VerifyAll()