11import httpretty
2+ import responses
23import pytest
34
45from plugins .fishbans import fishbans , bancount
@@ -34,90 +35,91 @@ class DummyBot():
3435 user_agent = "CloudBot/3.0"
3536
3637
37- @httpretty .activate
38+ @responses .activate
3839def test_bans ():
3940 """
4041 tests fishbans with a successful API response having multiple bans
4142 """
42- httpretty . register_uri ( httpretty .GET , 'http://api.fishbans.com/stats/notch/' , body = test_api )
43+ responses . add ( responses .GET , 'http://api.fishbans.com/stats/notch/' , body = test_api )
4344
4445 assert fishbans (test_user , DummyBot ) == bans_reply
4546
4647
47- @httpretty .activate
48+ @responses .activate
4849def test_bans_single ():
4950 """
5051 tests fishbans with a successful API response having a single ban
5152 """
52- httpretty . register_uri ( httpretty .GET , 'http://api.fishbans.com/stats/notch/' , body = test_api_single )
53+ responses . add ( responses .GET , 'http://api.fishbans.com/stats/notch/' , body = test_api_single )
5354
5455 assert fishbans (test_user , DummyBot ) == bans_reply_single
5556
5657
57- @httpretty .activate
58+ @responses .activate
5859def test_bans_failed ():
5960 """
6061 tests fishbans with a failed API response
6162 """
62- httpretty . register_uri ( httpretty .GET , 'http://api.fishbans.com/stats/notch/' , body = test_api_failed )
63+ responses . add ( responses .GET , 'http://api.fishbans.com/stats/notch/' , body = test_api_failed )
6364
6465 assert fishbans (test_user , DummyBot ) == reply_failed
6566
6667
67- @httpretty .activate
68+ @responses .activate
6869def test_bans_none ():
6970 """
7071 tests fishbans with a successful API response having no bans
7172 """
72- httpretty . register_uri ( httpretty .GET , 'http://api.fishbans.com/stats/notch/' , body = test_api_none )
73+ responses . add ( responses .GET , 'http://api.fishbans.com/stats/notch/' , body = test_api_none )
7374
7475 assert fishbans (test_user , DummyBot ) == bans_reply_none
7576
7677
77- @httpretty .activate
78+ @responses .activate
7879def test_bans_error ():
7980 """
8081 tests fishbans with a HTTP error
8182 """
82- httpretty . register_uri ( httpretty .GET , 'http://api.fishbans.com/stats/notch/' , status = 404 )
83+ responses . add ( responses .GET , 'http://api.fishbans.com/stats/notch/' , status = 404 )
8384
8485 assert fishbans (test_user , DummyBot ) == reply_error
8586
8687
87- @httpretty .activate
88+ @responses .activate
8889def test_count ():
8990 """
9091 tests bancount with a successful API response having multiple bans
9192 """
92- httpretty . register_uri ( httpretty .GET , 'http://api.fishbans.com/stats/notch/' , body = test_api )
93+ responses . add ( responses .GET , 'http://api.fishbans.com/stats/notch/' , body = test_api )
9394
9495 assert bancount (test_user , DummyBot ) == count_reply
9596
9697
97- @httpretty .activate
98+ @responses .activate
9899def test_count_failed ():
99100 """
100101 tests bancount with a failed API response
101102 """
102- httpretty . register_uri ( httpretty .GET , 'http://api.fishbans.com/stats/notch/' , body = test_api_failed )
103+ responses . add ( responses .GET , 'http://api.fishbans.com/stats/notch/' , body = test_api_failed )
103104
104105 assert bancount (test_user , DummyBot ) == reply_failed
105106
106107
107- @httpretty .activate
108+ @responses .activate
108109def test_count_none ():
109110 """
110111 tests bancount with a successful API response having no bans
111112 """
112- httpretty . register_uri ( httpretty .GET , 'http://api.fishbans.com/stats/notch/' , body = test_api_none )
113+ responses . add ( responses .GET , 'http://api.fishbans.com/stats/notch/' , body = test_api_none )
113114
114115 assert bancount (test_user , DummyBot ) == count_reply_none
115116
116- @httpretty .activate
117+
118+ @responses .activate
117119def test_count_error ():
118120 """
119121 tests bancount with a HTTP error
120122 """
121- httpretty . register_uri ( httpretty .GET , 'http://api.fishbans.com/stats/notch/' , status = 404 )
123+ responses . add ( responses .GET , 'http://api.fishbans.com/stats/notch/' , status = 404 )
122124
123125 assert bancount (test_user , DummyBot ) == reply_error
0 commit comments