Skip to content

Commit 3220fbd

Browse files
committed
pls work
1 parent 0359d89 commit 3220fbd

1 file changed

Lines changed: 84 additions & 89 deletions

File tree

plugins/test/test_fishbans.py

Lines changed: 84 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -27,98 +27,93 @@
2727
count_reply_none = "The user \x02notch\x02 has no bans - http://fishbans.com/u/notch/"
2828

2929
reply_failed = "Could not fetch ban data for notch."
30-
reply_error = "Could not fetch ban data from the Fishbans API: 404 Client Error: Not Found"
30+
reply_error = "Could not fetch ban data from the Fishbans API:"
3131

3232

3333
class DummyBot():
3434
user_agent = "CloudBot/3.0"
3535

3636

37-
@responses.activate
38-
def test_bans():
39-
"""
40-
tests fishbans with a successful API response having multiple bans
41-
"""
42-
responses.add(responses.GET, 'http://api.fishbans.com/stats/notch/', body=test_api)
43-
44-
assert fishbans(test_user, DummyBot) == bans_reply
45-
46-
47-
@responses.activate
48-
def test_bans_single():
49-
"""
50-
tests fishbans with a successful API response having a single ban
51-
"""
52-
responses.add(responses.GET, 'http://api.fishbans.com/stats/notch/', body=test_api_single)
53-
54-
assert fishbans(test_user, DummyBot) == bans_reply_single
55-
56-
57-
@responses.activate
58-
def test_bans_failed():
59-
"""
60-
tests fishbans with a failed API response
61-
"""
62-
responses.add(responses.GET, 'http://api.fishbans.com/stats/notch/', body=test_api_failed)
63-
64-
assert fishbans(test_user, DummyBot) == reply_failed
65-
66-
67-
@responses.activate
68-
def test_bans_none():
69-
"""
70-
tests fishbans with a successful API response having no bans
71-
"""
72-
responses.add(responses.GET, 'http://api.fishbans.com/stats/notch/', body=test_api_none)
73-
74-
assert fishbans(test_user, DummyBot) == bans_reply_none
75-
76-
77-
@responses.activate
78-
def test_bans_error():
79-
"""
80-
tests fishbans with a HTTP error
81-
"""
82-
responses.add(responses.GET, 'http://api.fishbans.com/stats/notch/', status=404)
83-
84-
assert fishbans(test_user, DummyBot) == reply_error
85-
86-
87-
@responses.activate
88-
def test_count():
89-
"""
90-
tests bancount with a successful API response having multiple bans
91-
"""
92-
responses.add(responses.GET, 'http://api.fishbans.com/stats/notch/', body=test_api)
93-
94-
assert bancount(test_user, DummyBot) == count_reply
95-
96-
97-
@responses.activate
98-
def test_count_failed():
99-
"""
100-
tests bancount with a failed API response
101-
"""
102-
responses.add(responses.GET, 'http://api.fishbans.com/stats/notch/', body=test_api_failed)
103-
104-
assert bancount(test_user, DummyBot) == reply_failed
105-
106-
107-
@responses.activate
108-
def test_count_none():
109-
"""
110-
tests bancount with a successful API response having no bans
111-
"""
112-
responses.add(responses.GET, 'http://api.fishbans.com/stats/notch/', body=test_api_none)
113-
114-
assert bancount(test_user, DummyBot) == count_reply_none
115-
116-
117-
@responses.activate
118-
def test_count_error():
119-
"""
120-
tests bancount with a HTTP error
121-
"""
122-
responses.add(responses.GET, 'http://api.fishbans.com/stats/notch/', status=404)
123-
124-
assert bancount(test_user, DummyBot) == reply_error
37+
class TestBans:
38+
@responses.activate
39+
def test_bans(self):
40+
"""
41+
tests fishbans with a successful API response having multiple bans
42+
"""
43+
responses.add(responses.GET, 'http://api.fishbans.com/stats/notch/', body=test_api)
44+
45+
assert fishbans(test_user, DummyBot) == bans_reply
46+
47+
@responses.activate
48+
def test_bans_single(self):
49+
"""
50+
tests fishbans with a successful API response having a single ban
51+
"""
52+
responses.add(responses.GET, 'http://api.fishbans.com/stats/notch/', body=test_api_single)
53+
54+
assert fishbans(test_user, DummyBot) == bans_reply_single
55+
56+
@responses.activate
57+
def test_bans_failed(self):
58+
"""
59+
tests fishbans with a failed API response
60+
"""
61+
responses.add(responses.GET, 'http://api.fishbans.com/stats/notch/', body=test_api_failed)
62+
63+
assert fishbans(test_user, DummyBot) == reply_failed
64+
65+
@responses.activate
66+
def test_bans_none(self):
67+
"""
68+
tests fishbans with a successful API response having no bans
69+
"""
70+
responses.add(responses.GET, 'http://api.fishbans.com/stats/notch/', body=test_api_none)
71+
72+
assert fishbans(test_user, DummyBot) == bans_reply_none
73+
74+
@responses.activate
75+
def test_bans_error(self):
76+
"""
77+
tests fishbans with a HTTP error
78+
"""
79+
responses.add(responses.GET, 'http://api.fishbans.com/stats/notch/', status=404)
80+
81+
assert fishbans(test_user, DummyBot).startswith(reply_error)
82+
83+
84+
class TestCount:
85+
@responses.activate
86+
def test_count(self):
87+
"""
88+
tests bancount with a successful API response having multiple bans
89+
"""
90+
responses.add(responses.GET, 'http://api.fishbans.com/stats/notch/', body=test_api)
91+
92+
assert bancount(test_user, DummyBot) == count_reply
93+
94+
@responses.activate
95+
def test_count_failed(self):
96+
"""
97+
tests bancount with a failed API response
98+
"""
99+
responses.add(responses.GET, 'http://api.fishbans.com/stats/notch/', body=test_api_failed)
100+
101+
assert bancount(test_user, DummyBot) == reply_failed
102+
103+
@responses.activate
104+
def test_count_none(self):
105+
"""
106+
tests bancount with a successful API response having no bans
107+
"""
108+
responses.add(responses.GET, 'http://api.fishbans.com/stats/notch/', body=test_api_none)
109+
110+
assert bancount(test_user, DummyBot) == count_reply_none
111+
112+
@responses.activate
113+
def test_count_error(self):
114+
"""
115+
tests bancount with a HTTP error
116+
"""
117+
responses.add(responses.GET, 'http://api.fishbans.com/stats/notch/', status=404)
118+
119+
assert bancount(test_user, DummyBot).startswith(reply_error)

0 commit comments

Comments
 (0)