-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: search transactions by learner email and content title
- Loading branch information
Showing
2 changed files
with
56 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -112,6 +112,7 @@ def setUp(self): | |
ledger=self.subsidy_2.ledger, | ||
lms_user_id=STATIC_LMS_USER_ID+1000, | ||
lms_user_email=self.lms_user_email, | ||
content_key=self.content_key_2, | ||
) | ||
|
||
# Create third subsidy with a different enterprise_customer_uuid. Neither test learner nor the test admin | ||
|
@@ -1353,6 +1354,56 @@ def test_fetch_transaction_with_external_reference(self): | |
response = self.client.get(os.path.join(url, str(transaction_with_external_reference.uuid) + "/")) | ||
assert response.json().get('external_reference') == [external_reference_id] | ||
|
||
@ddt.data( | ||
{ | ||
"role": "admin", | ||
"request_query_params": { | ||
"subsidy_uuid": APITestBase.subsidy_2_uuid, | ||
"search": "[email protected]" | ||
}, | ||
"expected_response_status": 200, | ||
"expected_response_uuids": [ | ||
APITestBase.subsidy_2_transaction_1_uuid, | ||
APITestBase.subsidy_2_transaction_2_uuid, | ||
], | ||
}, | ||
{ | ||
"role": "admin", | ||
"request_query_params": { | ||
"subsidy_uuid": APITestBase.subsidy_2_uuid, | ||
"search": "Test Course 2" | ||
}, | ||
"expected_response_status": 200, | ||
"expected_response_uuids": [ | ||
APITestBase.subsidy_2_transaction_2_uuid, | ||
], | ||
}, | ||
) | ||
@ddt.unpack | ||
def test_list_search(self, role, request_query_params, expected_response_status, expected_response_uuids): | ||
""" | ||
Test list Transactions permissions. | ||
""" | ||
if role == "admin": | ||
self.set_up_admin() | ||
elif role == "learner": | ||
self.set_up_learner() | ||
elif role == "operator": | ||
self.set_up_operator() | ||
url = reverse("api:v1:transaction-list") | ||
query_string = urllib.parse.urlencode(request_query_params) | ||
if query_string: | ||
query_string = "?" + query_string | ||
response = self.client.get(url + query_string) | ||
assert response.status_code == expected_response_status | ||
if response.status_code < 300: | ||
list_response_data = response.json()["results"] | ||
response_uuids = [tx["uuid"] for tx in list_response_data] | ||
assert ( | ||
set(response_uuids) - self.all_initial_transactions == | ||
set(expected_response_uuids) - self.all_initial_transactions | ||
) | ||
|
||
|
||
@ddt.ddt | ||
class ContentMetadataViewSetTests(APITestBase): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters