コード例 #1
0
 def test_verify_balance_behaviour(self, cred):
     """Test Verify Request to be free of charge if not verified.
     Balance is expected to remain the same after Verify Request
     and three unsuccessful Verify Check requests.
     """
     # check the initial balance
     resp = requests.get(balance_url.format(cred[0], cred[1]))
     assert resp.status_code == 200
     assert resp.headers['Content-Type'] == 'application/json;charset=UTF-8'
     start_balance = resp.json()['value']
     # now init the verification process
     resp = requests.get(
         verify_url.format('json', cred[0], cred[1], 'TestApp',
                           test_number))
     assert resp.status_code == 200
     assert resp.json()['status'] == '0'
     request_id = resp.json()['request_id']
     resp = requests.get(balance_url.format(cred[0], cred[1]))
     assert resp.status_code == 200
     assert start_balance == resp.json()['value']
     # terminate verification process
     assert 'Workflow terminated' in \
            terminate_workflow(cred[0], cred[1], request_id).json()['error_text']
     resp = requests.get(balance_url.format(cred[0], cred[1]))
     assert resp.status_code == 200
     assert start_balance == resp.json()['value']
コード例 #2
0
 def test_concurrent_verify_requests(self, cred):
     """Test concurrent Verify Request requests. Each subsequent
     request with the same number after the origin one should
     fail with status code 10.
     """
     # make the initial verification request
     resp = requests.get(
         verify_url.format('json', cred[0], cred[1], 'TestApp',
                           test_number))
     assert resp.status_code == 200
     assert resp.json()['status'] == '0'
     request_id = resp.json()['request_id']
     # try to repeate verification request three times
     for i in range(0, 3):
         resp = requests.get(
             verify_url.format('json', cred[0], cred[1], 'TestApp',
                               test_number))
         assert resp.status_code == 200
         assert resp.headers['Content-Type'] == 'application/json'
         assert resp.json()['status'] == '10'
         assert resp.json()['request_id'] == request_id
         assert resp.json()['error_text'] == concurrent_verifications_msg
     # terminate verification process
     assert 'Workflow terminated' in \
            terminate_workflow(cred[0], cred[1], request_id).json()['error_text']
コード例 #3
0
 def test_trigger_next_event_three_times(self, cred):
     """Test Verify Control trigger_next_event request.
     Should work successfully two times, after that should
     fail with status code 19.
     """
     # make the initial request
     resp = requests.get(
         verify_url.format('json', cred[0], cred[1], 'TestApp',
                           test_number))
     assert resp.status_code == 200
     assert resp.json()['status'] == '0'
     request_id = resp.json()['request_id']
     # make two trigger_next_event requests with small pauses
     for i in range(0, 2):
         time.sleep(10)
         resp = requests.get(
             control_url.format('json', cred[0], cred[1], request_id,
                                'trigger_next_event'))
         assert resp.status_code == 200
         assert resp.headers['Content-Type'] == 'application/json'
         assert resp.json()['status'] == '0'
         assert resp.json()['command'] == 'trigger_next_event'
     # perform third trigger_next_event request
     time.sleep(10)
     resp = requests.get(
         control_url.format('json', cred[0], cred[1], request_id,
                            'trigger_next_event'))
     assert resp.status_code == 200
     assert resp.headers['Content-Type'] == 'application/json'
     assert resp.json()['status'] == '19'
     assert resp.json(
     )['error_text'] == no_more_event_to_execute_msg.format(request_id)
     assert 'Workflow terminated' in \
            terminate_workflow(cred[0], cred[1], request_id).json()['error_text']
コード例 #4
0
 def test_valid_brand_format(self, cred, brand):
     """Test Verify request with various valid brand values.
     Each request should be successful with status code 0.
     """
     resp = requests.get(
         verify_url.format('json', cred[0], cred[1], brand, test_number))
     assert resp.status_code == 200
     assert resp.headers['Content-Type'] == 'application/json'
     assert resp.json()['status'] == '0'
     request_id = resp.json()['request_id']
     # terminate verification process
     assert 'Workflow terminated' in \
            terminate_workflow(cred[0], cred[1], request_id).json()['error_text']
コード例 #5
0
 def test_invalid_format_code_for_verification(self, cred, code):
     """Test Verify Check request with various invalid non-numeric
     code values. Each one should fail with status code 3.
     """
     resp = requests.get(
         verify_url.format('json', cred[0], cred[1], 'TestApp',
                           test_number))
     assert resp.status_code == 200
     assert resp.json()['status'] == '0'
     request_id = resp.json()['request_id']
     resp = requests.get(
         check_url.format('json', cred[0], cred[1], request_id, code))
     assert resp.status_code == 200
     assert resp.headers['Content-Type'] == 'application/json'
     assert resp.json()['status'] == '3'
     assert resp.json()['error_text'] == code_invalid_characters_msg
     # terminate verification process
     assert 'Workflow terminated' in \
            terminate_workflow(cred[0], cred[1], request_id).json()['error_text']
コード例 #6
0
 def test_empty_code_for_verification(self, cred):
     """Test Verify Check request with empty code.
     Should fail with status code 2.
     """
     resp = requests.get(
         verify_url.format('json', cred[0], cred[1], 'TestApp',
                           test_number))
     assert resp.status_code == 200
     assert resp.json()['status'] == '0'
     request_id = resp.json()['request_id']
     resp = requests.get(
         check_url.format('json', cred[0], cred[1], request_id, ''))
     assert resp.status_code == 200
     assert resp.headers['Content-Type'] == 'application/json'
     assert resp.json()['status'] == '2'
     assert resp.json(
     )['error_text'] == missing_specific_mandatory_parm_msg.format('code')
     # terminate verification process
     assert 'Workflow terminated' in \
            terminate_workflow(cred[0], cred[1], request_id).json()['error_text']
コード例 #7
0
 def test_invalid_cmd_for_verify_control(self, cred, cmd):
     """Test Verify Control request with some invalid cmd values.
     Each one should fail with status code 3.
     """
     resp = requests.get(
         verify_url.format('json', cred[0], cred[1], 'TestApp',
                           test_number))
     assert resp.status_code == 200
     assert resp.json()['status'] == '0'
     request_id = resp.json()['request_id']
     resp = requests.get(
         control_url.format('json', cred[0], cred[1], request_id, cmd))
     assert resp.status_code == 200
     assert resp.headers['Content-Type'] == 'application/json'
     assert resp.json()['status'] == '3'
     assert resp.json()['error_text'] == invalid_parameter_found_msg.format(
         'cmd')
     # terminate verification process
     assert 'Workflow terminated' in \
            terminate_workflow(cred[0], cred[1], request_id).json()['error_text']