def test_delete(self):
        connection = MagicMock()
        connection.make_request.return_value = {}

        order = Orders({'id': 1}, _connection=connection)

        self.assertEqual(order.delete(), {})

        connection.make_request.assert_called_once_with('DELETE', 'orders/1', None, None, None)
    def test_update(self):
        connection = MagicMock()
        connection.make_request.return_value = {'id': 1}

        order = Orders({'id': 1}, _connection=connection)
        new_order = order.update(name='order')
        self.assertIsInstance(new_order, Orders)

        connection.make_request.assert_called_once_with('PUT', 'orders/1', {'name': 'order'}, None, None)
Пример #3
0
    def test_delete(self):
        connection = MagicMock()
        connection.make_request.return_value = {}

        order = Orders({'id': 1}, _connection=connection)

        self.assertEqual(order.delete(), {})

        connection.make_request.assert_called_once_with(
            'DELETE', 'orders/1', None, None, None)
Пример #4
0
    def test_update(self):
        connection = MagicMock()
        connection.make_request.return_value = {'id': 1}

        order = Orders({'id': 1}, _connection=connection)
        new_order = order.update(name='order')
        self.assertIsInstance(new_order, Orders)

        connection.make_request.assert_called_once_with(
            'PUT', 'orders/1', {'name': 'order'}, None, None)
    def test_all(self):
        connection = MagicMock()
        connection.make_request.return_value = [{'id': 1}, {'id': 2}, {'id': 2}]

        result = Orders.all(connection, limit=3)
        self.assertEqual(len(list(result)), 3)
        connection.make_request.assert_called_once_with('GET', 'orders', None, {'limit': 3}, None)
    def test_delete_all(self):
        connection = MagicMock()
        connection.make_request.return_value = {}

        self.assertEqual(Orders.delete_all(connection), {})

        connection.make_request.assert_called_once_with('DELETE', 'orders', None, None, None)
    def test_create(self):
        connection = MagicMock()
        connection.make_request.return_value = {'id': 1}

        result = Orders.create(connection, name="Hello")
        self.assertIsInstance(result, Orders)
        self.assertEqual(result.id, 1)
        connection.make_request.assert_called_once_with('POST', 'orders', {'name': 'Hello'}, None, None)
Пример #8
0
    def test_init(self):
        result = {'coupons': {'url': 'blah'}, 'id': 1}

        map = Orders(result)
        self.assertEqual(map.id, 1)
        self.assertEqual(map['id'], 1)

        self.assertNotIsInstance(map.coupons, dict)
Пример #9
0
    def test_delete_all(self):
        connection = MagicMock()
        connection.make_request.return_value = {}

        self.assertEqual(Orders.delete_all(connection), {})

        connection.make_request.assert_called_once_with(
            'DELETE', 'orders', None, None, None)
Пример #10
0
    def test_all(self):
        connection = MagicMock()
        connection.make_request.return_value = [{'id': 1}, {'id': 2}]

        result = Orders.all(connection, limit=2)
        self.assertEqual(len(result), 2)
        connection.make_request.assert_called_once_with(
            'GET', 'orders', None, {'limit': 2}, {})
    def test_get(self):
        connection = MagicMock()
        connection.make_request.return_value = {'id': 1}

        result = Orders.get(1, connection)
        self.assertIsInstance(result, Orders)
        self.assertEqual(result.id, 1)

        connection.make_request.assert_called_once_with('GET', 'orders/1', None, {}, None)
Пример #12
0
    def test_create(self):
        connection = MagicMock()
        connection.make_request.return_value = {'id': 1}

        result = Orders.create(connection, name="Hello")
        self.assertIsInstance(result, Orders)
        self.assertEqual(result.id, 1)
        connection.make_request.assert_called_once_with(
            'POST', 'orders', {'name': 'Hello'}, None, None)
Пример #13
0
    def test_get(self):
        connection = MagicMock()
        connection.make_request.return_value = {'id': 1}

        result = Orders.get(1, connection)
        self.assertIsInstance(result, Orders)
        self.assertEqual(result.id, 1)

        connection.make_request.assert_called_once_with(
            'GET', 'orders/1', None, {}, None)