10000 Migrated TestGitHubStatus to tests/{unit/integration} · pythonthings/github3.py@8362f52 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8362f52

Browse files
itsmemattchungsigmavirus24
authored andcommitted
Migrated TestGitHubStatus to tests/{unit/integration}
1 parent 1d8cebe commit 8362f52

File tree

8 files changed

+82
-37
lines changed

8 files changed

+82
-37
lines changed

tests/cassettes/GitHubStatus_api.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"http_interactions": [{"request": {"body": {"string": "", "encoding": "utf-8"}, "headers": {"Accept-Encoding": "gzip, deflate", "Accept": "application/vnd.github.v3.full+json", "User-Agent": "github3.py/1.0.0a2", "Accept-Charset": "utf-8", "Connection": "keep-alive", "Content-Type": "application/json"}, "method": "GET", "uri": "https://status.github.com/api.json"}, "response": {"body": {"string": "{\"status_url\":\"https://status.github.com/api/status.json\",\"messages_url\":\"https://status.github.com/api/messages.json\",\"last_message_url\":\"https://status.github.com/api/last-message.json\",\"daily_summary\":\"https://status.github.com/api/daily-summary.json\"}", "encoding": null}, "headers": {"status": "200 OK", "content-length": "255", "strict-transport-security": "max-age=31536000", "server": "GitHub.com", "connection": "keep-alive", "date": "Sat, 16 Jan 2016 17:44:01 GMT", "content-type": "application/json", "timing-allow-origin": "https://github.com", "x-octostatus-request-id": "3647a93f-0d77-40bb-9a24-468ad4066aa1"}, "status": {"message": "OK", "code": 200}, "url": "https://status.github.com/api.json"}, "recorded_at": "2016-01-16T17:44:01"}], "recorded_with": "betamax/0.5.0"}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"http_interactions": [{"request": {"body": {"string": "", "encoding": "utf-8"}, "headers": {"Accept-Encoding": "gzip, deflate", "Accept": "application/vnd.github.v3.full+json", "User-Agent": "github3.py/1.0.0a2", "Accept-Charset": "utf-8", "Connection": "keep-alive", "Content-Type": "application/json"}, "method": "GET", "uri": "https://status.github.com/api/last-message.json"}, "response": {"body": {"string": "{\"status\":\"good\",\"body\":\"Everything operating normally.\",\"created_on\":\"2016-01-08T02:31:09Z\"}", "encoding": null}, "headers": {"status": "200 OK", "content-length": "93", "strict-transport-security": "max-age=31536000", "server": "GitHub.com", "connection": "keep-alive", "date": "Sat, 16 Jan 2016 17:47:17 GMT", "content-type": "application/json", "timing-allow-origin": "https://github.com", "x-octostatus-request-id": "63f57c38-7cfc-4acf-9ca2-492bff06ef1e"}, "status": {"message": "OK", "code": 200}, "url": "https://status.github.com/api/last-message.json"}, "recorded_at": "2016-01-16T17:47:17"}], "recorded_with": "betamax/0.5.0"}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"http_interactions": [{"request": {"body": {"string": "", "encoding": "utf-8"}, "headers": {"Accept-Encoding": "gzip, deflate", "Accept": "application/vnd.github.v3.full+json", "User-Agent": "github3.py/1.0.0a2", "Accept-Charset": "utf-8", "Connection": "keep-alive", "Content-Type": "application/json"}, "method": "GET", "uri": "https://status.github.com/api/messages.json"}, "response": {"body": {"string": "[]", "encoding": null}, "headers": {"status": "200 OK", "content-length": "2", "strict-transport-security": "max-age=31536000", "server": "GitHub.com", "connection": "keep-alive", "date": "Sat, 16 Jan 2016 17:48:29 GMT", "content-type": "application/json", "timing-allow-origin": "https://github.com", "x-octostatus-request-id": "406d6327-f08e-49fd-923d-1794db44b936"}, "status": {"message": "OK", "code": 200}, "url": "https://status.github.com/api/messages.json"}, "recorded_at": "2016-01-16T17:48:29"}], "recorded_with": "betamax/0.5.0"}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"http_interactions": [{"request": {"body": {"string": "", "encoding": "utf-8"}, "headers": {"Accept-Encoding": "gzip, deflate", "Accept": "application/vnd.github.v3.full+json", "User-Agent": "github3.py/1.0.0a2", "Accept-Charset": "utf-8", "Connection": "keep-alive", "Content-Type": "application/json"}, "method": "GET", "uri": "https://status.github.com/api/status.json"}, "response": {"body": {"string": "{\"status\":\"good\",\"last_updated\":\"2016-01-16T17:45:26Z\"}", "encoding": null}, "headers": {"status": "200 OK", "content-length": "55", "strict-transport-security": "max-age=31536000", "server": "GitHub.com", "connection": "keep-alive", "date": "Sat, 16 Jan 2016 17:45:35 GMT", "content-type": "application/json", "timing-allow-origin": "https://github.com", "x-octostatus-request-id": "3ac45328-508d-4dfa-90f5-c750b0023d12"}, "status": {"message": "OK", "code": 200}, "url": "https://status.github.com/api/status.json"}, "recorded_at": "2016-01-16T17:45:35"}], "recorded_with": "betamax/0.5.0"}

tests/integration/helper.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,9 @@ class GitHubEnterpriseHelper(IntegrationHelper):
6161

6262
def get_client(self):
6363
return github3.GitHubEnterprise(self.enterprise_url)
64+
65+
66+
class GitHubStatusHelper(IntegrationHelper):
67+
68+
def get_client(self):
69+
return github3.GitHubStatus()

tests/integration/test_github.py

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import github3
44
import uritemplate
55

6-
from .helper import GitHubEnterpriseHelper, IntegrationHelper
7-
6+
from .helper import (GitHubEnterpriseHelper, IntegrationHelper,
7+
GitHubStatusHelper)
88

99
SSH_KEY = (
1010
# Generated for this alone then deleted
@@ -580,3 +580,41 @@ def test_admin_stats(self):
580580
stats = self.gh.admin_stats('all')
581581

582582
assert isinstance(stats, dict)
583+
584+
585+
class TestGitHubStatus(GitHubStatusHelper):
586+
587+
def setUp(self):
588+
super(TestGitHubStatus, self).setUp()
589+
590+
def test_api(self):
591+
"""Test the ability to check the status of /api."""
592+
cassette_name = self.cassette_name('api')
593+
with self.recorder.use_cassette(cassette_name):
594+
api = self.gh.api()
595+
596+
assert isinstance(api, dict)
597+
598+
def test_last_message(self):
599+
"""Test the ability to check the status of /api/last-message."""
600+
cassette_name = self.cassette_name('last_message')
601+
with self.recorder.use_cassette(cassette_name):
602+
last_message = self.gh.last_message()
603+
604+
assert isinstance(last_message, dict)
605+
606+
def test_messages(self):
607+
"""Test the ability to check the status of /api/messages."""
608+
cassette_name = self.cassette_name('messages')
609+
with self.recorder.use_cassette(cassette_name):
610+
messages = self.gh.messages()
611+
612+
assert isinstance(messages, list)
613+
614+
def test_status(self):
615+
"""Test the ability to check the status of /api/status."""
616+
cassette_name = self.cassette_name('status')
617+
with self.recorder.use_cassette(cassette_name):
618+
status = self.gh.status()
619+
620+
assert isinstance(status, dict)

tests/test_github.py

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -15,37 +15,3 @@ def test_skip_ssl_validation(self):
1515

1616
assert False == self.g.session.verify
1717
assert self.request.called
18-
19-
20-
class TestGitHubStatus(BaseCase):
21-
def setUp(self):
22-
super(TestGitHubStatus, self).setUp()
23-
self.g = github3.GitHubStatus()
24-
self.api = 'https://status.github.com/'
25-
26-
def test_repr(self):
27-
assert repr(self.g) == '<GitHub Status>'
28-
29-
def test_api(self):
30-
self.response('user')
31-
self.get(self.api + 'api.json')
32-
assert isinstance(self.g.api(), dict)
33-
self.mock_assertions()
34-
35-
def test_status(self):
36-
self.response('user')
37-
self.get(self.api + 'api/status.json')
38-
assert isinstance(self.g.status(), dict)
39-
self.mock_assertions()
40-
41-
def test_last_message(self):
42-
self.response('user')
43-
self.get(self.api + 'api/last-message.json')
44-
assert isinstance(self.g.last_message(), dict)
45-
self.mock_assertions()
46-
47-
def test_messages(self):
48-
self.response('user')
49-
self.get(self.api + 'api/messages.json')
50-
assert isinstance(self.g.messages(), dict)
51-
self.mock_assertions()

tests/unit/test_github.py

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import pytest
22

33
from github3 import AuthenticationFailed, GitHubEnterprise, GitHubError
4-
from github3.github import GitHub
4+
from github3.github import GitHub, GitHubStatus
55

66
from . import helper
77

@@ -1384,3 +1384,34 @@ def test_str(self):
13841384
assert str(self.instance) == '<GitHub Enterprise [{0}]>'.format(
13851385
enterprise_url_for()
13861386
)
1387+
1388+
1389+
class TestGitHubStatus(helper.UnitHelper):
1390+
1391+
"""Test methods on GitHubStatus."""
1392+
1393+
described_class = GitHubStatus
1394+
1395+
def test_api(self):
1396+
"""Verify the request for /api."""
1397+
with helper.mock.patch.object(GitHubStatus, '_recipe') as _recipe:
1398+
self.instance.api()
1399+
_recipe.assert_called_once_with('api.json')
1400+
1401+
def test_last_message(self):
1402+
"""Verify the request for /api/last-message."""
1403+
with helper.mock.patch.object(GitHubStatus, '_recipe') as _recipe:
1404+
self.instance.last_message()
1405+
_recipe.assert_called_once_with('api', 'last-message.json')
1406+
1407+
def test_messages(self):
1408+
"""Verify the request for /api/messages."""
1409+
with helper.mock.patch.object(GitHubStatus, '_recipe') as _recipe:
1410+
self.instance.messages()
1411+
_recipe.assert_called_once_with('api', 'messages.json')
1412+
1413+
def test_status(self):
1414+
"""Verify the request for /api/status."""
1415+
with helper.mock.patch.object(GitHubStatus, '_recipe') as _recipe:
1416+
self.instance.status()
1417+
_recipe.assert_called_once_with('api', 'status.json')

0 commit comments

Comments
 (0)
0