Ejemplo n.º 1
0
 def test_size(self):
     # Check default size == 64
     default_url = parse.urlparse(schema_utils.user_avatar_url("testuser"))
     assert ("s", "64") in parse.parse_qsl(default_url.query)
     # Check a different size
     custom_url = parse.urlparse(
         schema_utils.user_avatar_url("testuser", size=128))
     assert ("s", "128") in parse.parse_qsl(custom_url.query)
Ejemplo n.º 2
0
    def agent_avatar(self) -> typing.Union[None, str]:
        """
        Return a URL to the avatar of the user who caused the action.

        Returns:
            The URL to the user's avatar, or None if username is None.
        """
        username = self.agent
        if username is None:
            return None
        return user_avatar_url(username)
Ejemplo n.º 3
0
 def agent_avatar(self):
     return user_avatar_url(self.agent)
Ejemplo n.º 4
0
 def agent_avatar(self):
     """An URL to the avatar of the user who caused the action."""
     from_header = self.body["from"]
     return schema_utils.user_avatar_url(from_header)
Ejemplo n.º 5
0
 def test_different_default(self):
     url = schema_utils.user_avatar_url("testuser", default="testdefault")
     assert ("d",
             "testdefault") in parse.parse_qsl(parse.urlparse(url).query)
Ejemplo n.º 6
0
 def test_base(self):
     expected = (
         "https://seccdn.libravatar.org/avatar/"
         "7cebe82e9588dcccabc7f32d50901befeb4dfa42baf08044791feea4b48b2e34"
         "?s=64&d=retro")
     assert schema_utils.user_avatar_url("testuser") == expected