Beispiel #1
0
    def test_index_with_limit_and_offset(self):
        msg1 = stubs.stub_message(fakes.get_fake_uuid())
        msg2 = stubs.stub_message(fakes.get_fake_uuid())
        self.mock_object(message_api.API, 'get_all',
                         mock.Mock(return_value=[msg1, msg2]))
        req = fakes.HTTPRequest.blank(
            '/messages?limit=1&offset=1',
            version=messages.MESSAGES_BASE_MICRO_VERSION,
            base_url='http://localhost/v2')
        req.environ['manila.context'] = self.ctxt

        res_dict = self.controller.index(req)

        ex2 = self._expected_message_from_controller(msg2['id'])['message']
        self.assertEqual([ex2], res_dict['messages'])
Beispiel #2
0
    def test_index_with_limit_and_offset(self):
        msg1 = stubs.stub_message(fakes.get_fake_uuid())
        msg2 = stubs.stub_message(fakes.get_fake_uuid())
        self.mock_object(message_api.API, 'get_all', mock.Mock(
                         return_value=[msg1, msg2]))
        req = fakes.HTTPRequest.blank(
            '/messages?limit=1&offset=1',
            version=messages.MESSAGES_BASE_MICRO_VERSION,
            base_url='http://localhost/v2')
        req.environ['manila.context'] = self.ctxt

        res_dict = self.controller.index(req)

        ex2 = self._expected_message_from_controller(msg2['id'])['message']
        self.assertEqual([ex2], res_dict['messages'])
Beispiel #3
0
    def test_index_with_created_since_and_created_before(self):
        msg = stubs.stub_message(fakes.get_fake_uuid(),
                                 created_at=datetime.datetime(
                                     1900, 2, 1, 1, 1, 1, tzinfo=iso8601.UTC))
        self.mock_object(message_api.API, 'get_all',
                         mock.Mock(return_value=[msg]))
        req = fakes.HTTPRequest.blank(
            '/messages?created_since=1900-01-01T01:01:01&'
            'created_before=1900-03-01T01:01:01',
            version=messages.MESSAGES_QUERY_BY_TIMESTAMP,
            base_url='http://localhost/v2')
        req.environ['manila.context'] = self.ctxt

        res_dict = self.controller.index(req)

        ex2 = self._expected_message_from_controller(
            msg['id'],
            created_at=datetime.datetime(1900,
                                         2,
                                         1,
                                         1,
                                         1,
                                         1,
                                         tzinfo=iso8601.UTC))['message']
        self.assertEqual([ex2], res_dict['messages'])
Beispiel #4
0
    def test_index(self):
        msg1 = stubs.stub_message(fakes.get_fake_uuid())
        msg2 = stubs.stub_message(fakes.get_fake_uuid())
        self.mock_object(message_api.API, 'get_all',
                         mock.Mock(return_value=[msg1, msg2]))
        req = fakes.HTTPRequest.blank(
            '/messages',
            version=messages.MESSAGES_BASE_MICRO_VERSION,
            base_url='http://localhost/v2')
        req.environ['manila.context'] = self.ctxt

        res_dict = self.controller.index(req)

        ex1 = self._expected_message_from_controller(msg1['id'])['message']
        ex2 = self._expected_message_from_controller(msg2['id'])['message']
        expected = {'messages': [ex1, ex2]}
        self.assertDictMatch(expected, res_dict)
Beispiel #5
0
    def test_index(self):
        msg1 = stubs.stub_message(fakes.get_fake_uuid())
        msg2 = stubs.stub_message(fakes.get_fake_uuid())
        self.mock_object(message_api.API, 'get_all', mock.Mock(
                         return_value=[msg1, msg2]))
        req = fakes.HTTPRequest.blank(
            '/messages',
            version=messages.MESSAGES_BASE_MICRO_VERSION,
            base_url='http://localhost/v2')
        req.environ['manila.context'] = self.ctxt

        res_dict = self.controller.index(req)

        ex1 = self._expected_message_from_controller(msg1['id'])['message']
        ex2 = self._expected_message_from_controller(msg2['id'])['message']
        expected = {'messages': [ex1, ex2]}
        self.assertDictMatch(expected, res_dict)