def test_get_order(self):
        client = ordering_client.OrderingClient()

        response = client.get_order('1')

        self.assertEquals({'id': '1'}, response)

        ordering_client.requests.get.assert_called_once_with(
            'http://localhost:8080/DSProductOrdering/api/productOrdering/v2/productOrder/1'
        )
        self._response.raise_for_status.assert_called_once_with()
Esempio n. 2
0
    def test_ordering_subscription(self):
        client = ordering_client.OrderingClient()

        client.create_ordering_subscription()

        # Check calls
        ordering_client.requests.post.assert_called_once_with(
            'http://localhost:8080/DSProductOrdering/productOrdering/v2/hub', {
                'callback':
                'http://testdomain.com/charging/api/orderManagement/orders'
            })
    def test_update_state(self):
        client = ordering_client.OrderingClient()
        new_state = 'Failed'

        order = {'id': '7'}

        client.update_state(order, new_state)

        ordering_client.requests.patch.assert_called_once_with(
            'http://localhost:8080/DSProductOrdering/api/productOrdering/v2/productOrder/'
            + order['id'],
            json={'state': new_state})

        self._response.raise_for_status.assert_called_once_with()
    def test_ordering_subscription_error(self):
        client = ordering_client.OrderingClient()
        self._response.status_code = 400

        error = None
        try:
            client.create_ordering_subscription()
        except ImproperlyConfigured as e:
            error = e

        self.assertFalse(error is None)
        msg = "It hasn't been possible to create ordering subscription, "
        msg += 'please check that the ordering API is correctly configured '
        msg += 'and that the ordering API is up and running'

        self.assertEquals(msg, unicode(e))
    def test_update_items_state(self, name, expected, items=None):
        client = ordering_client.OrderingClient()
        order = {
            'id':
            '20',
            'orderItem': [{
                'id': '1',
                'state': 'Acknowledged'
            }, {
                'id': '2',
                'state': 'Acknowledged'
            }]
        }
        client.update_items_state(order, 'InProgress', items)

        ordering_client.requests.patch.assert_called_once_with(
            'http://localhost:8080/DSProductOrdering/api/productOrdering/v2/productOrder/20',
            json=expected)

        self._response.raise_for_status.assert_called_once_with()