1616from weblate .accounts .apps import check_avatars
1717from weblate .auth .models import User
1818from weblate .trans .tests .test_views import FixtureTestCase
19- from weblate .utils .tests import http_mock as responses
19+ from weblate .utils .tests import http_mock
2020
2121TEST_URL = (
2222 "https://www.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?d=identicon&s=32"
@@ -44,13 +44,13 @@ def test_fallback_avatar_uses_stable_url(self) -> None:
4444 "https://cdn.example.com/static/api-32.png" ,
4545 )
4646
47- @responses .activate
47+ @http_mock .activate
4848 def test_avatar (self ) -> None :
4949 image = Image .new ("RGB" , (32 , 32 ))
5050 storage = BytesIO ()
5151 image .save (storage , "PNG" )
5252 imagedata = storage .getvalue ()
53- responses . add ( responses . GET , TEST_URL , body = imagedata )
53+ http_mock . register ( " GET" , TEST_URL , content = imagedata )
5454 # Real user
5555 response = self .client .get (
5656 reverse ("user_avatar" , kwargs = {"user" : self .user .username , "size" : 32 })
@@ -64,9 +64,9 @@ def test_avatar(self) -> None:
6464 self .assert_png (response )
6565 self .assertEqual (response .content , imagedata )
6666
67- @responses .activate
67+ @http_mock .activate
6868 def test_avatar_error (self ) -> None :
69- responses . add ( responses . GET , TEST_URL , status = 503 )
69+ http_mock . register ( " GET" , TEST_URL , status_code = 503 )
7070 # Choose different username to avoid using cache
7171 self .user .username = "test2"
7272 self .user .save ()
@@ -86,13 +86,13 @@ def test_avatar_check_handles_http_error(self) -> None:
8686 self .assertEqual (len (errors ), 1 )
8787 self .assertEqual (errors [0 ].id , "weblate.E018" )
8888
89- @responses .activate
89+ @http_mock .activate
9090 def test_avatar_rejects_unsupported_size_before_fetch (self ) -> None :
9191 response = self .client .get (
9292 reverse ("user_avatar" , kwargs = {"user" : self .user .username , "size" : 999 })
9393 )
9494 self .assertEqual (response .status_code , 404 )
95- self .assertEqual (len (responses .calls ), 0 )
95+ self .assertEqual (len (http_mock .calls ), 0 )
9696
9797 def test_anonymous_avatar (self ) -> None :
9898 anonymous = User .objects .get (username = "anonymous" )
0 commit comments