Here are the examples of the python api mock.Request taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
5 Examples
3
Source : test_sap_adt_cts.py
with Apache License 2.0
from jfilak
with Apache License 2.0
from jfilak
def test_get_transport_requests(self):
connection = Connection([Response(SHORTENED_WORKBENCH_XML, 200, {})])
workbench = sap.adt.cts.Workbench(connection)
transport = workbench.get_transport_requests(user=CTS_OWNER)
self.assertEqual(
connection.execs,
[Request('GET',
f'/sap/bc/adt/cts/transportrequests',
{'Accept': 'application/vnd.sap.adt.transportorganizertree.v1+xml, application/vnd.sap.adt.transportorganizer.v1+xml'},
None,
sap.adt.cts.workbench_params(CTS_OWNER))])
self.assert_trasport_equal(transport[0], connection)
self.assert_task_equal(transport[0].tasks[0], connection)
@patch('sap.adt.cts.Workbench.get_transport_requests')
3
Source : test_sap_rest_gcts.py
with Apache License 2.0
from jfilak
with Apache License 2.0
from jfilak
def test_not_json_response(self):
req = Request(method='GET', adt_uri='/epic/success', headers=None, body=None, params=None)
res = Response(status_code=401, text='Not JSON')
orig_error = UnauthorizedError(req, res, 'foo')
new_error = sap.rest.gcts.errors.exception_from_http_error(orig_error)
self.assertEqual(new_error, orig_error)
def test_repository_does_not_exist(self):
3
Source : test_sap_rest_gcts.py
with Apache License 2.0
from jfilak
with Apache License 2.0
from jfilak
def test_repository_does_not_exist(self):
messages = {'exception': 'No relation between system and repository'}
req = Request(method='GET', adt_uri='/epic/success', headers=None, body=None, params=None)
res = Response.with_json(status_code=500, json=messages)
orig_error = HTTPRequestError(req, res)
new_error = sap.rest.gcts.errors.exception_from_http_error(orig_error)
expected_error = sap.rest.gcts.errors.GCTSRepoNotExistsError(messages)
self.assertEqual(str(new_error), str(expected_error))
class GCTSTestSetUp:
3
Source : test_sap_rest_gcts.py
with Apache License 2.0
from jfilak
with Apache License 2.0
from jfilak
def test_delete_ok(self):
repo = sap.rest.gcts.remote_repo.Repository(self.conn, self.repo_name, data=self.repo_server_data)
repo.delete()
self.assertIsNone(repo._data)
self.assertEqual(len(self.conn.execs), 1)
self.conn.execs[0].assertEqual(Request(method='DELETE', adt_uri=f'repository/{self.repo_name}', params=None, headers=None, body=None), self)
def test_delete_error(self):
0
Source : test_sap_adt_atc.py
with Apache License 2.0
from jfilak
with Apache License 2.0
from jfilak
def setUp(self):
self.variant = 'ACT_VARIANT'
self.worklist_id = 'WORKLIST_ID'
self.request_create_worklist = Request(method='POST',
adt_uri='/sap/bc/adt/atc/worklists',
params={'checkVariant': self.variant},
headers={'Accept': 'text/plain'},
body=None)
self.request_run_worklist = Request(method='POST',
adt_uri='/sap/bc/adt/atc/runs',
params={'worklistId': self.worklist_id},
headers={'Accept': 'application/xml',
'Content-Type': 'application/xml'},
body=ADT_XML_ATC_RUN_REQUEST_PACKAGE)
self.request_get_worklist = Request(method='GET',
adt_uri=f'/sap/bc/adt/atc/worklists/{self.worklist_id}',
params={'includeExemptedFindings': 'false'},
headers={'Accept': 'application/atc.worklist.v1+xml'},
body=None)
self.conn = Connection([Response(status_code=200,
text=self.worklist_id,
headers={'Content-Type': 'text/plain'}),
Response(status_code=200,
text=ADT_XML_ATC_RUN_RESPONSE_NO_OBJECTS,
headers={'Content-Type': 'application/xml'}),
Response(status_code=200,
text=ADT_XML_ATC_WORKLIST_EMPTY,
headers={'Content-Type': 'application/atc.worklist.v1+xml'})])
self.checks_runner = sap.adt.atc.ChecksRunner(self.conn, self.variant)
def test_get_id(self):