Example #1
0
 def test_pagure_missing_avatar(self, mock_call_api):
     mock_call_api.return_value = {}
     expected = (
         "https://seccdn.libravatar.org/avatar/"
         "9c9f7784935381befc302fe3c814f9136e7a33953d0318761669b8643f4df55c")
     actual = PagureService()._avatar("ralph")
     self.assertEqual(actual.split("?")[0], expected)
Example #2
0
    def test_pagure_missing_avatar(self, mock_call_api):
        base_avatar_url = (
            "https://seccdn.libravatar.org/avatar/"
            "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbccccccccccccccc")
        pagure_avatar_url = base_avatar_url + "?s=16&d=retro"
        mock_call_api.return_value = {
            'user': {
                'avatar_url': pagure_avatar_url
            }
        }

        expected_query = "s=64&d=retro"
        expected = base_avatar_url + "?" + expected_query

        actual = PagureService()._avatar("ralph")
        self.assertEqual(actual.split("?")[0], base_avatar_url)
        actual_query = urllib.parse.parse_qs(
            urllib.parse.urlparse(actual).query)
        self.assertEqual(actual_query, urllib.parse.parse_qs(expected_query))