def test_constructor(self):
        post_id = "1234"
        image_id = "5324543"
        link = f"https://furaffinity.net/view/{post_id}/"
        thumb_link = f"https://t.facdn.net/{post_id}@400-{image_id}.jpg"
        full_link = f"https://d.facdn.net/art/fender/{image_id}/{image_id}.fender_blah-de-blah.jpg"
        title = "Example post"
        author = FAUser.from_short_dict({"name": "John", "profile_name": "john"})
        description = "This is an example post for testing"
        keywords = ["example", "test"]
        rating = Rating.GENERAL

        submission = FASubmissionFull(
            post_id, thumb_link, full_link, full_link, title, author, description, keywords, rating
        )

        assert isinstance(submission, FASubmissionFull)
        assert submission.submission_id == post_id
        assert submission.link == link
        assert submission.thumbnail_url == thumb_link
        assert submission.full_image_url == full_link
        assert submission.download_url == full_link
        assert submission.title == title
        assert submission.author == author
        assert submission.description == description
        assert submission.keywords == keywords
        assert submission.rating == rating
Esempio n. 2
0
 def __init__(self,
              submission_id: Union[str, int],
              *,
              username: str = None,
              image_id: int = None,
              file_size: int = 14852,
              file_ext: str = "jpg",
              fav_id: str = None,
              title: str = None,
              author: FAUser = None,
              description: str = None,
              keywords: List[str] = None,
              thumbnail_url: str = None,
              download_url: str = None,
              full_image_url: str = None,
              rating: Rating = None):
     # Internal variables
     if image_id is None:
         image_id = _random_image_id(int(submission_id))
     if username is None:
         username = _random_string()
     if fav_id is None:
         fav_id = str(_random_image_id(int(submission_id)))
     folder = ""
     if file_ext in FASubmission.EXTENSIONS_AUDIO:
         folder = "music/"
     if file_ext in FASubmission.EXTENSIONS_DOCUMENT:
         folder = "stories/"
     # Variables for superclass
     if thumbnail_url is None:
         thumbnail_url = f"https://t.facdn.net/{submission_id}@1600-{image_id}.jpg"
     if download_url is None:
         download_url = f"https://d.facdn.net/art/{username}/{folder}{image_id}/" \
             f"{image_id}.{username}_{_random_string()}.{file_ext}"
     if full_image_url is None:
         if file_ext in FASubmission.EXTENSIONS_PHOTO + ["gif"]:
             full_image_url = download_url
         else:
             full_image_url = download_url + ".jpg"
     if title is None:
         title = _random_string()
     if author is None:
         profile_name = _random_string()
         author = FAUser.from_submission_dict({
             "name": profile_name.title(),
             "profile_name": profile_name
         })
     if description is None:
         description = _random_string() * 5
     if keywords is None:
         keywords = [_random_string() for _ in range(3)]
     if rating is None:
         rating = _random_rating()
     # Super
     super().__init__(str(submission_id), thumbnail_url, download_url,
                      full_image_url, title, author, description, keywords,
                      rating)
     self.fav_id = fav_id
     self._download_file_size = file_size
    def test_constructor(self):
        name = "John"
        profile_name = "john"

        author = FAUser(name, profile_name)

        assert author.name == name
        assert author.profile_name == profile_name
        assert f"/user/{profile_name}" in author.link
    def test_from_submission_dict(self):
        name = "John"
        profile_name = "john"

        author = FAUser.from_submission_dict(
            {
                "name": name,
                "profile_name": profile_name
            }
        )

        assert author.name == name
        assert author.profile_name == profile_name
        assert f"/user/{profile_name}" in author.link
    def test_to_inline_query_result(self):
        post_id = "1234"
        image_id = "5324543"
        link = f"https://furaffinity.net/view/{post_id}/"
        thumb_url = f"https://t.facdn.net/{post_id}@1600-{image_id}.jpg"
        title = "Example post"
        author = FAUser.from_short_dict({"name": "John", "profile_name": "john"})
        submission = FASubmissionShort(post_id, thumb_url, title, author)

        query_result = submission.to_inline_query_result()

        assert query_result.id == post_id
        assert query_result.photo_url == thumb_url
        assert query_result.thumb_url == FASubmission.make_thumbnail_smaller(thumb_url)
        assert query_result.caption == link
    def test_constructor(self):
        post_id = "1234"
        image_id = "5324543"
        link = f"https://furaffinity.net/view/{post_id}/"
        thumb_link = f"https://t.facdn.net/{post_id}@400-{image_id}.jpg"
        title = "Example post"
        author = FAUser.from_short_dict({"name": "John", "profile_name": "john"})

        submission = FASubmissionShort(post_id, thumb_link, title, author)

        assert isinstance(submission, FASubmissionShort)
        assert submission.submission_id == post_id
        assert submission.link == link
        assert submission.thumbnail_url == thumb_link
        assert submission.title == title
        assert submission.author == author
 def __init__(self,
              *,
              submission_id: Union[str, int] = None,
              username: str = None,
              image_id: int = None,
              file_size: int = None,
              thumb_size: int = None,
              file_ext: str = "jpg",
              fav_id: str = None,
              title: str = None,
              author: FAUser = None,
              description: str = None,
              keywords: List[str] = None,
              rating: Rating = None):
     if submission_id is None:
         submission_id = random.randint(10_000, 100_000)
     submission_id = str(submission_id)
     # Internal variables
     if image_id is None:
         image_id = _random_image_id(int(submission_id))
     if username is None:
         if author is None:
             username = _random_string()
         else:
             username = author.profile_name
     folder = ""
     if file_ext in FASubmission.EXTENSIONS_AUDIO:
         folder = "music/"
     if file_ext in FASubmission.EXTENSIONS_DOCUMENT:
         folder = "stories/"
     if thumb_size is None:
         thumb_size = 1600
     # Variables for superclass
     thumbnail_url = f"https://t.facdn.net/{submission_id}@{thumb_size}-{image_id}.jpg"
     download_url = f"https://d.facdn.net/art/{username}/{folder}{image_id}/" \
         f"{image_id}.{username}_{_random_string()}.{file_ext}"
     if file_ext in FASubmission.EXTENSIONS_PHOTO + ["gif"]:
         full_image_url = download_url
     else:
         full_image_url = download_url + ".jpg"
     if title is None:
         title = _random_string()
     if author is None:
         author = FAUser.from_submission_dict({
             "name": username.title(),
             "profile_name": username
         })
     if description is None:
         description = _random_string() * 5
     if keywords is None:
         keywords = [_random_string() for _ in range(3)]
     if rating is None:
         rating = Rating.GENERAL
     # Set all the variables
     self.submission_id = submission_id
     self.link = f"https://furaffinity.net/view/{submission_id}/"
     self.thumbnail_url = thumbnail_url
     self.title = title
     self.author = author
     self.download_url = download_url
     self.full_image_url = full_image_url
     self.description = description
     self.rating = rating
     self.keywords = keywords
     self.fav_id = fav_id
     self._image_id = image_id
     self._file_ext = file_ext
     self._download_file_size = file_size