-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[MSUE-151] [MSUE-191] - Integration testing files #99
base: master
Are you sure you want to change the base?
[MSUE-151] [MSUE-191] - Integration testing files #99
Conversation
# Get the value of API_KEY from environment variable | ||
api_key = env['API_KEY'] | ||
|
||
client = sift.Client(api_key = api_key, account_id = 'ACCT') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
account_id is probablky optional
} | ||
} | ||
|
||
response = client.verification_send(sendProperties) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need to add assertion mechanism so that the cases fail when a particular condition is not met. For now we can just test the status
in the response code which should be 0 for all successful calls
@@ -0,0 +1 @@ | |||
from decisions_api import test_decisions_api |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: extra line
@@ -0,0 +1 @@ | |||
from workflows_api import test_workflows_api |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: empty extra line should be provided
@@ -0,0 +1 @@ | |||
from score_api import test_score_api |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra line is missing
assert(response.is_ok()) | ||
assert response.api_status == 0, "api_status should be 0" | ||
assert response.api_error_message == "OK", "api_error_message should be OK" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the same code used in different tests. We may use something like utils.py
file with the functions that can be reused
test_integration_app/main.py
Outdated
from labels_api import test_labels_api | ||
from psp_merchant_api import test_psp_merchant_api | ||
|
||
#Events APIs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why all those are commented out?
test_integration_app/main.py
Outdated
#Events APIs | ||
|
||
# test_events_api.add_item_to_cart() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: we can remove the spaces between the calls
@@ -0,0 +1 @@ | |||
from psp_merchant_api import test_psp_merchant_api |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: extra line is missing
@@ -0,0 +1 @@ | |||
from verifications_api import test_verification_api |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra line is missing
test_sift_verification_apis.py
Outdated
def test_verification_send(): | ||
client = sift.Client(api_key='valid-api-key', account_id='ACCT') | ||
response = client.verification_send(sendProperties) | ||
print(response) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why we print the result instead of checking the response?
test_sift_verification_apis.py
Outdated
def test_verification_resend(): | ||
client = sift.Client(api_key='valid-api-key', account_id='ACCT') | ||
response = client.verification_resend(resendProperties) | ||
print(response) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the same as above
test_sift_verification_apis.py
Outdated
def test_verification_check(): | ||
client = sift.Client(api_key='valid-api-key', account_id='ACCT') | ||
response = client.verification_check(checkProperties) | ||
print(response) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the same as above
test_sift_verification_apis.py
Outdated
test_verification_send() | ||
|
||
# test_verification_resend() | ||
|
||
# test_verification_check() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be moved to the main.py
under the test_integration_app
test_sift_verification_apis.py
Outdated
else: | ||
import urllib.parse | ||
|
||
def response_with_data_header(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why we need this one?
test_sift_verification_apis.py
Outdated
import sift | ||
import sys | ||
|
||
if sys.version_info[0] < 3: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is okay for us to concentrate only on Python 3 in these tests so feel free to remove all that is not related to Pythion 3
test_sift_verification_apis.py
Outdated
} | ||
|
||
def test_verification_send(): | ||
client = sift.Client(api_key='valid-api-key', account_id='ACCT') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how this one is expected to work with this api_key
?
|
||
def get_user_score(): | ||
response = client.get_user_score("[email protected]") | ||
print(response) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't need to print the results, it is okay just to run. Feel free to remove in other places as well
@haneeshv several things
|
Not required, created for testing purpose
test_integration_app/main.py
Outdated
def runAllMethods(): | ||
objUtils = Utils() | ||
objEvents = test_events_api.EventsAPI() | ||
ObjDecision = test_decisions_api.DecisionAPI() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: capital letter for ObjDecision
test_integration_app/main.py
Outdated
|
||
assert (objUtils.isOK(objVerification.send()) == True) | ||
assert (objUtils.isOK(objVerification.resend()) == True) | ||
assert (objUtils.isOK(objVerification.check()) == True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@haneeshv how this one gonna work? The expectation is that this call will fail since the code will be wrong
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggested:
res = objVerification.check()
assert (objUtils.isOK(res) == True)
assert. res.status == 50
"$verified_value" : "14155551212" | ||
} | ||
return self.client.track("$verification", verification_properties) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: too many extra lines
|
||
def get_merchant_profiles(self, batch_token = None, batch_size = None): | ||
return self.client.get_psp_merchant_profiles(batch_token, batch_size) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bit: too many extra lines
return self.client.track('$create_order', properties, return_workflow_status=True, | ||
return_route_info=True, abuse_types=['promo_abuse', 'content_abuse', 'payment_abuse']) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: extra line
Release 5.5.0
assert (objUtils.isOK(objDecision.apply_user_decision()) == False) | ||
assert (objUtils.isOK(objDecision.apply_order_decision()) == False) | ||
assert (objUtils.isOK(objDecision.apply_session_decision()) == False) | ||
assert (objUtils.isOK(objDecision.apply_content_decision()) == False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why it is False?
|
||
def get_merchant_profiles(self, batch_token = None, batch_size = None): | ||
return self.client.get_psp_merchant_profiles(batch_token, batch_size) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: extra line
Purpose
Currently, we don’t perform any thorough testing before releasing sift-python lib. The idea of this task is to actually setup an integration app that is going to contain a set of tests we run against the lib before releasing it. Those tests should be performed against real Sift env (Sift prod account)
This integration app can be a representative template for other libs - eventually we want to have the same integration app for every single public lib we support
Summary
Methods created for Events, Decisions, Workflows, Score, Verification and PSP Merchant API
Testing
Methods are implemented and tested manually
Checklist