forked from sigmavirus24/github3.py
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_events.py
More file actions
95 lines (76 loc) · 3.2 KB
/
test_events.py
File metadata and controls
95 lines (76 loc) · 3.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import github3
import pytest
from tests.utils import BaseCase, load
from unittest import TestCase
class TestEvent(BaseCase):
def __init__(self, methodName='runTest'):
super(TestEvent, self).__init__(methodName)
self.ev = github3.events.Event(load('event'))
self.o = load('org')
def setUp(self):
super(TestEvent, self).setUp()
self.ev = github3.events.Event(self.ev.to_json())
def test_equality(self):
e = github3.events.Event(load('event'))
assert self.ev == e
e._uniq = 1
assert self.ev != e
def test_org(self):
json = self.ev.to_json().copy()
json['org'] = self.o
ev = github3.events.Event(json)
assert isinstance(ev.org, github3.orgs.Organization)
def test_repr(self):
assert repr(self.ev).startswith('<Event')
def test_list_types(self):
Event, handlers = (github3.events.Event,
github3.events._payload_handlers)
assert Event.list_types() == sorted(handlers.keys())
def test_is_public(self):
assert self.ev.is_public() == self.ev.public
class TestPayloadHandlers(TestCase):
def test_commitcomment(self):
comment = {'comment': load('repo_comment')}
comment = github3.events._commitcomment(comment, None)
assert isinstance(comment['comment'],
github3.repos.comment.RepoComment)
def test_follow(self):
f = {'target': load('user')}
github3.events._follow(f, None)
assert isinstance(f['target'], github3.users.User)
def test_forkev(self):
f = {'forkee': load('repo')}
github3.events._forkev(f, None)
assert isinstance(f['forkee'], github3.repos.Repository)
def test_gist(self):
g = {'gist': load('gist')}
github3.events._gist(g, None)
assert isinstance(g['gist'], github3.gists.Gist)
def test_issuecomm(self):
c = {'issue': load('issue'), 'comment': load('issue_comment')}
github3.events._issuecomm(c, None)
assert isinstance(c['issue'], github3.issues.Issue)
assert isinstance(c['comment'], github3.issues.comment.IssueComment)
def test_issueevent(self):
c = {'issue': load('issue')}
github3.events._issueevent(c, None)
assert isinstance(c['issue'], github3.issues.Issue)
def test_member(self):
m = {'member': load('user')}
github3.events._member(m, None)
assert isinstance(m['member'], github3.users.User)
def test_pullreqev(self):
p = {'pull_request': load('pull')}
github3.events._pullreqev(p, None)
assert isinstance(p['pull_request'], github3.pulls.PullRequest)
def test_pullreqcomm(self):
p = {'comment': load('review_comment')}
github3.events._pullreqcomm(p, None)
assert isinstance(p['comment'], github3.pulls.ReviewComment)
@pytest.mark.xfail
def test_team(payload):
t = {'team': load('team'), 'repo': load('repo'), 'user': load('user')}
github3.events._team(t, None)
assert isinstance(t['team'], github3.orgs.Team)
assert isinstance(t['repo'], github3.repos.Repository)
assert isinstance(t['user'], github3.users.User)