-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added code related to onboarding status and onboarding timestamp and added few test cases related to the same. * Added code related to onboarding status and onboarding timestamp and added few test cases related to the same. * Added code related to onboarding status and onboarding timestamp and added few test cases related to the same. * Added code related to onboarding status and onboarding timestamp and added few test cases related to the same. * Added code related to onboarding status and onboarding timestamp and added few test cases related to the same. * Added code related to onboarding status and onboarding timestamp and added few test cases related to the same.
- Loading branch information
1 parent
25efad2
commit e58b75a
Showing
6 changed files
with
230 additions
and
8 deletions.
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
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
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
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
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 |
---|---|---|
|
@@ -2688,6 +2688,142 @@ def test_get_executor_logs(get_executor_logs): | |
assert actual["data"]["logs"][0]['bot'] == pytest.bot | ||
|
||
|
||
def test_update_user_details_with_invalid_onboarding_status(): | ||
response = client.post( | ||
"/api/user/details/Invalid", | ||
headers={"Authorization": pytest.token_type + " " + pytest.access_token}, | ||
) | ||
|
||
actual = response.json() | ||
assert not actual["success"] | ||
assert actual["error_code"] == 422 | ||
assert not actual["data"] | ||
assert actual["message"] == "Invalid is not a valid status" | ||
|
||
response = client.post( | ||
"/api/user/details/INITIATED", | ||
headers={"Authorization": pytest.token_type + " " + pytest.access_token}, | ||
) | ||
|
||
actual = response.json() | ||
assert not actual["success"] | ||
assert actual["error_code"] == 422 | ||
assert not actual["data"] | ||
assert actual["message"] == "INITIATED is not a valid status" | ||
|
||
response = client.post( | ||
"/api/user/details/IN PROGRESS", | ||
headers={"Authorization": pytest.token_type + " " + pytest.access_token}, | ||
) | ||
|
||
actual = response.json() | ||
assert not actual["success"] | ||
assert actual["error_code"] == 422 | ||
assert not actual["data"] | ||
assert actual["message"] == "IN PROGRESS is not a valid status" | ||
|
||
response = client.post( | ||
"/api/user/details/Done", | ||
headers={"Authorization": pytest.token_type + " " + pytest.access_token}, | ||
) | ||
|
||
actual = response.json() | ||
assert not actual["success"] | ||
assert actual["error_code"] == 422 | ||
assert not actual["data"] | ||
assert actual["message"] == "Done is not a valid status" | ||
|
||
|
||
def test_update_user_details_with_onboarding_status(): | ||
response = client.get( | ||
"/api/user/details", | ||
headers={"Authorization": pytest.token_type + " " + pytest.access_token}, | ||
).json() | ||
assert response["data"]["user"]["_id"] | ||
assert response["data"]["user"]["email"] == "[email protected]" | ||
assert ( | ||
response["data"]["user"]["bots"]["account_owned"][0]["user"] | ||
== "[email protected]" | ||
) | ||
assert response["data"]["user"]["bots"]["account_owned"][0]["timestamp"] | ||
assert response["data"]["user"]["bots"]["account_owned"][0]["name"] | ||
assert response["data"]["user"]["bots"]["account_owned"][0]["_id"] | ||
assert not response["data"]["user"]["bots"]["shared"] | ||
assert response["data"]["user"]["timestamp"] | ||
assert response["data"]["user"]["status"] | ||
assert response["data"]["user"]["account_name"] == "integration" | ||
assert response["data"]["user"]["first_name"] == "Demo" | ||
assert response["data"]["user"]["last_name"] == "User" | ||
assert response["data"]["user"]["onboarding_status"] == "Not Completed" | ||
assert response["data"]["user"]["is_onboarded"] is False | ||
|
||
response = client.post( | ||
"/api/user/details/In Progress", | ||
headers={"Authorization": pytest.token_type + " " + pytest.access_token}, | ||
) | ||
|
||
actual = response.json() | ||
assert actual["success"] | ||
assert actual["error_code"] == 0 | ||
assert actual["message"] == "Details updated!" | ||
|
||
response = client.get( | ||
"/api/user/details", | ||
headers={"Authorization": pytest.token_type + " " + pytest.access_token}, | ||
).json() | ||
assert response["data"]["user"]["_id"] | ||
assert response["data"]["user"]["email"] == "[email protected]" | ||
assert ( | ||
response["data"]["user"]["bots"]["account_owned"][0]["user"] | ||
== "[email protected]" | ||
) | ||
assert response["data"]["user"]["bots"]["account_owned"][0]["timestamp"] | ||
assert response["data"]["user"]["bots"]["account_owned"][0]["name"] | ||
assert response["data"]["user"]["bots"]["account_owned"][0]["_id"] | ||
assert not response["data"]["user"]["bots"]["shared"] | ||
assert response["data"]["user"]["timestamp"] | ||
assert response["data"]["user"]["status"] | ||
assert response["data"]["user"]["account_name"] == "integration" | ||
assert response["data"]["user"]["first_name"] == "Demo" | ||
assert response["data"]["user"]["last_name"] == "User" | ||
assert response["data"]["user"]["onboarding_status"] == "In Progress" | ||
assert response["data"]["user"]["onboarding_timestamp"] | ||
assert response["data"]["user"]["is_onboarded"] is False | ||
|
||
response = client.post( | ||
"/api/user/details/Completed", | ||
headers={"Authorization": pytest.token_type + " " + pytest.access_token}, | ||
) | ||
|
||
actual = response.json() | ||
assert actual["success"] | ||
assert actual["error_code"] == 0 | ||
assert actual["message"] == "Details updated!" | ||
|
||
response = client.get( | ||
"/api/user/details", | ||
headers={"Authorization": pytest.token_type + " " + pytest.access_token}, | ||
).json() | ||
assert response["data"]["user"]["_id"] | ||
assert response["data"]["user"]["email"] == "[email protected]" | ||
assert ( | ||
response["data"]["user"]["bots"]["account_owned"][0]["user"] | ||
== "[email protected]" | ||
) | ||
assert response["data"]["user"]["bots"]["account_owned"][0]["timestamp"] | ||
assert response["data"]["user"]["bots"]["account_owned"][0]["name"] | ||
assert response["data"]["user"]["bots"]["account_owned"][0]["_id"] | ||
assert not response["data"]["user"]["bots"]["shared"] | ||
assert response["data"]["user"]["timestamp"] | ||
assert response["data"]["user"]["status"] | ||
assert response["data"]["user"]["account_name"] == "integration" | ||
assert response["data"]["user"]["first_name"] == "Demo" | ||
assert response["data"]["user"]["last_name"] == "User" | ||
assert response["data"]["user"]["onboarding_status"] == "Completed" | ||
assert response["data"]["user"]["onboarding_timestamp"] | ||
assert response["data"]["user"]["is_onboarded"] is True | ||
|
||
|
||
def test_get_collection_data_with_no_collection_data(): | ||
response = client.get( | ||
url=f"/api/bot/{pytest.bot}/data/collection", | ||
|
@@ -12628,7 +12764,7 @@ def test_get_user_details(): | |
|
||
def test_update_user_details(): | ||
response = client.post( | ||
"/api/user/details", | ||
"/api/user/details/Completed", | ||
headers={"Authorization": pytest.token_type + " " + pytest.access_token}, | ||
) | ||
|
||
|
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 |
---|---|---|
|
@@ -2835,3 +2835,72 @@ def test_get_attributes(self): | |
attributes = AuditDataProcessor.get_attributes(document) | ||
assert attributes[0]['key'] == 'email' | ||
assert attributes[0]['value'] == '[email protected]' | ||
|
||
def test_update_user_details_with_invalid_onboarding_status(self): | ||
with pytest.raises(ValidationError, match="Invalid is not a valid status"): | ||
AccountProcessor.update_user_details("[email protected]", "Invalid") | ||
|
||
with pytest.raises(ValidationError, match="INITIATED is not a valid status"): | ||
AccountProcessor.update_user_details("[email protected]", "INITIATED") | ||
|
||
with pytest.raises(ValidationError, match="IN PROGRESS is not a valid status"): | ||
AccountProcessor.update_user_details("[email protected]", "IN PROGRESS") | ||
|
||
with pytest.raises(ValidationError, match="Done is not a valid status"): | ||
AccountProcessor.update_user_details("[email protected]", "Done") | ||
|
||
def test_update_user_details_with_onboarding_status(self): | ||
assert len(AccountProcessor.get_accessible_bot_details(pytest.account, "[email protected]")['account_owned']) == 1 | ||
user_details = AccountProcessor.get_complete_user_details("[email protected]") | ||
assert user_details["_id"] | ||
assert user_details["email"] == "[email protected]" | ||
assert user_details["bots"]["account_owned"][0]["user"] == "[email protected]" | ||
assert user_details["bots"]["account_owned"][0]["timestamp"] | ||
assert user_details["bots"]["account_owned"][0]["name"] == "test_bot" | ||
assert user_details["bots"]["account_owned"][0]["_id"] | ||
assert not user_details["bots"]["shared"] | ||
assert user_details["timestamp"] | ||
assert user_details["status"] | ||
assert user_details["account_name"] == "paypal" | ||
assert user_details["first_name"] == "Fahad Ali" | ||
assert user_details["last_name"] == "Shaikh" | ||
assert user_details["onboarding_status"] == "Not Completed" | ||
assert user_details["is_onboarded"] is False | ||
|
||
AccountProcessor.update_user_details("[email protected]", "In Progress") | ||
|
||
user_details = AccountProcessor.get_complete_user_details("[email protected]") | ||
assert user_details["_id"] | ||
assert user_details["email"] == "[email protected]" | ||
assert user_details["bots"]["account_owned"][0]["user"] == "[email protected]" | ||
assert user_details["bots"]["account_owned"][0]["timestamp"] | ||
assert user_details["bots"]["account_owned"][0]["name"] == "test_bot" | ||
assert user_details["bots"]["account_owned"][0]["_id"] | ||
assert not user_details["bots"]["shared"] | ||
assert user_details["timestamp"] | ||
assert user_details["status"] | ||
assert user_details["account_name"] == "paypal" | ||
assert user_details["first_name"] == "Fahad Ali" | ||
assert user_details["last_name"] == "Shaikh" | ||
assert user_details["onboarding_status"] == "In Progress" | ||
assert user_details["onboarding_timestamp"] | ||
assert user_details["is_onboarded"] is False | ||
|
||
AccountProcessor.update_user_details("[email protected]", "Completed") | ||
|
||
user_details = AccountProcessor.get_complete_user_details("[email protected]") | ||
assert user_details["_id"] | ||
assert user_details["email"] == "[email protected]" | ||
assert user_details["bots"]["account_owned"][0]["user"] == "[email protected]" | ||
assert user_details["bots"]["account_owned"][0]["timestamp"] | ||
assert user_details["bots"]["account_owned"][0]["name"] == "test_bot" | ||
assert user_details["bots"]["account_owned"][0]["_id"] | ||
assert not user_details["bots"]["shared"] | ||
assert user_details["timestamp"] | ||
assert user_details["status"] | ||
assert user_details["account_name"] == "paypal" | ||
assert user_details["first_name"] == "Fahad Ali" | ||
assert user_details["last_name"] == "Shaikh" | ||
assert user_details["onboarding_status"] == "Completed" | ||
assert user_details["onboarding_timestamp"] | ||
assert user_details["is_onboarded"] is True |