Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
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)
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)
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(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_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_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)
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)