Skip to content

Commit

Permalink
Added document to transaction test and order test
Browse files Browse the repository at this point in the history
  • Loading branch information
riadelimemmedov committed Mar 22, 2024
1 parent 2563ef6 commit 6a678a3
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
16 changes: 15 additions & 1 deletion backend/config/tests/order/test_endpoint_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,21 @@
class TestOrderEndpoints:
endpoint = "/orders/create-checkout-session/"

def test_create_pet(self, pet_factory_end_to_end, api_client):
def test_create_order(self, api_client):
"""
Test the creation of an order using the provided API client.
Args:
self: The instance of the test case.
api_client: The API client used to make the HTTP request.
Returns:
None
Raises:
AssertionError: If the response status code is not HTTP 201 (Created).
"""
data = b'{"pets":[[{"type":"BigNumber","hex":"0x02"},"rocky","Rocky","#FF29C4",{"type":"BigNumber","hex":"0x23"},"https://images.unsplash.com/photo-1537019575197-df34a13f342c?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=1338&q=40"],[{"type":"BigNumber","hex":"0x01"},"frieda","Frieda","#D92DFF",{"type":"BigNumber","hex":"0x20"},"https://images.unsplash.com/photo-1600682011352-e448301668e7?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=1348&q=40"]],"from_user":"0x3c44cdddb6a900fa2b585dd299e03d12fa4293bc"}'
response = api_client().post(
self.endpoint,
Expand Down
30 changes: 30 additions & 0 deletions backend/config/tests/transaction/test_endpoint_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,42 @@ class TestTransactionEndpoints:
endpoint = "/transactions/"

def test_return_all_transactions(self, transaction_factory, api_client):
"""
Test the API's ability to return all transactions in a batch.
Args:
self: The instance of the test case.
transaction_factory: The transaction factory used to generate the test data.
api_client: The API client used to make the HTTP request.
Returns:
None
Raises:
AssertionError: If the response status code is not HTTP 200 (OK) or if the length of the returned JSON content is not equal to the number of transactions created.
"""
transaction_factory.create_batch(4)
response = api_client().get(self.endpoint, format="json")
assert response.status_code == status.HTTP_200_OK
assert len(json.loads(response.content)) == 4

def test_create_transaction(self, transaction_factory, api_client):
"""
Test the API's ability to create a new transaction.
Args:
self: The instance of the test case.
transaction_factory: The transaction factory used to generate the test data.
api_client: The API client used to make the HTTP request.
Returns:
None
Raises:
AssertionError: If the response status code is not HTTP 201 (Created).
"""
data = {
"from_user": "0x3c44cdddb6a900fa2b585dd299e03d12fa4293bc",
"confirmations": 1,
Expand Down

0 comments on commit 6a678a3

Please sign in to comment.