summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorClark Boylan <clark.boylan@gmail.com>2020-04-28 15:45:51 -0700
committerClark Boylan <clark.boylan@gmail.com>2020-04-28 15:45:51 -0700
commite255397eb4dabf9c7ce8b38f18f894bd26e3c874 (patch)
treee16c0591c53cc120340b445803b5bc1662022497 /tests
parent6ef4f078aa4466794834ac5a266296ec8e367c16 (diff)
downloadzuul-e255397eb4dabf9c7ce8b38f18f894bd26e3c874.tar.gz
Simplify FakeGithubClient and FakeGithubSession
These two fakes are related to each other. Before this change FakeGithubClient would create a FakeGithubSession and FakeGithubSession would create FakeGithubClients. THis recursion is confusing and unnecessary. Under normal operation the FakeGithubClient exists first so we pass it into its FakeGithubSessions and the fake session is able to use this client object rather than recursively creating a new client. Change-Id: I9ff52061d62e844ca3f2185ea752ca39962b2a9f
Diffstat (limited to 'tests')
-rw-r--r--tests/fakegithub.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/tests/fakegithub.py b/tests/fakegithub.py
index bbcbb6aa2..558d23471 100644
--- a/tests/fakegithub.py
+++ b/tests/fakegithub.py
@@ -555,8 +555,8 @@ class FakeResponse(object):
class FakeGithubSession(object):
- def __init__(self, data):
- self._data = data
+ def __init__(self, client):
+ self.client = client
self.headers = CaseInsensitiveDict()
self._base_url = None
self.schema = graphene.Schema(query=FakeGithubQuery)
@@ -584,7 +584,7 @@ class FakeGithubSession(object):
query = json.get('query')
variables = json.get('variables')
result = self.schema.execute(
- query, variables=variables, context=self._data)
+ query, variables=variables, context=self.client._data)
return FakeResponse({'data': result.data}, 200)
return FakeResponse(None, 404)
@@ -593,8 +593,7 @@ class FakeGithubSession(object):
org, project, request = request.split('/', 2)
project_name = '{}/{}'.format(org, project)
- client = FakeGithubClient(self._data)
- repo = client.repo_from_project(project_name)
+ repo = self.client.repo_from_project(project_name)
return repo.get_url(request, params=params)
@@ -618,7 +617,7 @@ class FakeGithubClient(object):
def __init__(self, data, inst_id=None):
self._data = data
self._inst_id = inst_id
- self.session = FakeGithubSession(data)
+ self.session = FakeGithubSession(self)
def user(self, login):
return FakeUser(login)