def test_create_short_dict_makes_thumb_bigger_75(self): builder = SubmissionBuilder(thumb_size=75) big_thumb_link = builder.thumbnail_url.replace("@75-", "@1600-") submission = FASubmission.from_short_dict( builder.build_search_json() ) assert submission.thumbnail_url == big_thumb_link
def test_get_browse_page_specify_page(self, r): builder = SubmissionBuilder() api = FAExportAPI("http://example.com/") r.get(f"http://example.com/browse.json?page=5", json=[builder.build_search_json()]) results = api.get_browse_page(5) assert len(results) == 1 assert isinstance(results[0], FASubmissionShort) assert results[0].submission_id == builder.submission_id
def test_get_search_results_specified_page(self, r): builder = SubmissionBuilder() search = "deer" api = FAExportAPI("http://example.com/") r.get( f"http://example.com/search.json?full=1&perpage=48&q={search}&page=2", json=[builder.build_search_json()]) results = api.get_search_results(search, 2) assert len(results) == 1 assert isinstance(results[0], FASubmissionShort) assert results[0].submission_id == builder.submission_id
def test_get_search_results_with_extended_modifiers(self, r): builder = SubmissionBuilder() search = "(deer & !lion) | (goat & !tiger)" search_safe = "(deer%20&%20!lion)%20%7C%20(goat%20&%20!tiger)" api = FAExportAPI("http://example.com/") r.get( f"http://example.com/search.json?full=1&perpage=48&q={search_safe}&page=1", json=[builder.build_search_json()]) results = api.get_search_results(search) assert len(results) == 1 assert isinstance(results[0], FASubmissionShort) assert results[0].submission_id == builder.submission_id
def test_get_search_results(self, r): post_id1 = "32342" post_id2 = "32337" builder1 = SubmissionBuilder(submission_id=post_id1) builder2 = SubmissionBuilder(submission_id=post_id2) search = "deer" api = FAExportAPI("http://example.com/") r.get( f"http://example.com/search.json?full=1&perpage=48&q={search}&page=1", json=[builder1.build_search_json(), builder2.build_search_json()]) results = api.get_search_results(search) assert len(results) == 2 assert isinstance(results[0], FASubmissionShort) assert isinstance(results[1], FASubmissionShort) assert results[0].submission_id == post_id1 assert results[1].submission_id == post_id2 assert results[0].link == f"https://furaffinity.net/view/{post_id1}/" assert results[1].link == f"https://furaffinity.net/view/{post_id2}/" assert results[0].thumbnail_url == builder1.thumbnail_url assert results[1].thumbnail_url == builder2.thumbnail_url
def test_get_user_folder_specified_page(self, r): builder = SubmissionBuilder() username = "******" api = FAExportAPI("http://example.com/") r.get(f"http://example.com/user/{username}/gallery.json?page=2&full=1", json=[builder.build_search_json()]) results = api.get_user_folder(username, "gallery", 2) assert len(results) == 1 assert isinstance(results[0], FASubmissionShort) assert results[0].submission_id == builder.submission_id assert results[0].link == builder.link assert results[0].thumbnail_url == builder.thumbnail_url
def test_get_user_folder(self, r): post_id1 = "32342" post_id2 = "32337" builder1 = SubmissionBuilder(submission_id=post_id1) builder2 = SubmissionBuilder(submission_id=post_id2) username = "******" api = FAExportAPI("http://example.com/") r.get( f"http://example.com/user/{username}/gallery.json?page=1&full=1", json=[builder1.build_search_json(), builder2.build_search_json()]) results = api.get_user_folder(username, "gallery") assert len(results) == 2 for result in results: assert isinstance(result, FASubmissionShort) assert results[0].submission_id == post_id1 assert results[1].submission_id == post_id2 assert results[0].link == f"https://furaffinity.net/view/{post_id1}/" assert results[1].link == f"https://furaffinity.net/view/{post_id2}/" assert results[0].thumbnail_url == builder1.thumbnail_url assert results[1].thumbnail_url == builder2.thumbnail_url
def test_get_user_folder_awkward_characters(self, r): builder = SubmissionBuilder() username = "******" safe_username = "******" api = FAExportAPI("http://example.com/") r.get( f"http://example.com/user/{safe_username}/gallery.json?page=1&full=1", json=[builder.build_search_json()]) results = api.get_user_folder(username, "gallery") assert len(results) == 1 assert isinstance(results[0], FASubmissionShort) assert results[0].submission_id == builder.submission_id assert results[0].link == builder.link assert results[0].thumbnail_url == builder.thumbnail_url
def test_create_from_short_dict(self): builder = SubmissionBuilder() submission = FASubmission.from_short_dict( builder.build_search_json() ) assert isinstance(submission, FASubmissionShort) assert submission.submission_id == builder.submission_id assert submission.link == builder.link assert submission.thumbnail_url == builder.thumbnail_url assert submission.title == builder.title assert submission.author.profile_name == builder.author.profile_name assert submission.author.name == builder.author.name assert submission.author.link == builder.author.link