Skip to content

Commit

Permalink
Fix gerrit tests.
Browse files Browse the repository at this point in the history
Mock out the request added to service initialization.
  • Loading branch information
ryneeverett committed Apr 8, 2017
1 parent 0c93796 commit faf9d4c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
4 changes: 4 additions & 0 deletions tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ class ServiceTest(ConfigTest):
SERVICE_CONFIG = {
}

@classmethod
def setUpClass(cls):
cls.maxDiff = None

def get_mock_service(
self, service_class, section='unspecified',
config_overrides=None, general_overrides=None
Expand Down
13 changes: 9 additions & 4 deletions tests/test_gerrit.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class TestGerritIssue(AbstractServiceTest, ServiceTest):
SERVICE_CONFIG = {
'gerrit.base_uri': 'https://one',
'gerrit.base_uri': 'https://one.com',
'gerrit.username': 'two',
'gerrit.password': 'three',
}
Expand All @@ -27,6 +27,11 @@ class TestGerritIssue(AbstractServiceTest, ServiceTest):

def setUp(self):
super(TestGerritIssue, self).setUp()

responses.add(
responses.HEAD,
self.SERVICE_CONFIG['gerrit.base_uri'] + '/a/',
adding_headers={'www-authenticate': 'digest'})
self.service = self.get_mock_service(GerritService)

def test_to_taskwarrior(self):
Expand Down Expand Up @@ -56,18 +61,18 @@ def test_to_taskwarrior(self):
@responses.activate
def test_issues(self):
self.add_response(
'https://one/a/changes/?q=is:open+is:reviewer&o=MESSAGES&o=DETAILED_ACCOUNTS',
'https://one.com/a/changes/?q=is:open+is:reviewer&o=MESSAGES&o=DETAILED_ACCOUNTS',
# The response has some ")]}'" garbage prefixed.
body=")]}'" + json.dumps([self.record]))

issue = next(self.service.issues())

expected = {
'annotations': [u'@Iam Author - is is a message'],
'description': u'(bw)PR#1 - this is a title .. https://one/#/c/1/',
'description': u'(bw)PR#1 - this is a title .. https://one.com/#/c/1/',
'gerritid': 1,
'gerritsummary': u'this is a title',
'gerriturl': 'https://one/#/c/1/',
'gerriturl': 'https://one.com/#/c/1/',
'gerritbranch': 'master',
'gerrittopic': 'test-topic',
'priority': 'M',
Expand Down

0 comments on commit faf9d4c

Please sign in to comment.