1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-01 16:51:11 +03:00

Merge pull request #2819 from ryanpetrello/fix-busted-tests

mock an HTTP call to fix busted unit tests

Reviewed-by: https://github.com/softwarefactory-project-zuul[bot]
This commit is contained in:
softwarefactory-project-zuul[bot] 2018-11-28 14:50:38 +00:00 committed by GitHub
commit d9866c35b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -221,8 +221,12 @@ class TestHostInsights():
assert resp.status_code == 404
def test_get_insights_user_agent(self, patch_parent, mocker):
resp = HostInsights()._get_insights('https://example.org', 'joe', 'example')
assert re.match(r'AWX [^\s]+ \(open\)', resp.request.headers['User-Agent'])
with mock.patch.object(requests.Session, 'get') as get:
HostInsights()._get_insights('https://example.org', 'joe', 'example')
assert get.call_count == 1
args, kwargs = get.call_args_list[0]
assert args == ('https://example.org',)
assert re.match(r'AWX [^\s]+ \(open\)', kwargs['headers']['User-Agent'])
class TestSurveySpecValidation: