text
stringlengths
1
93.6k
class TestMethods(unittest.TestCase):
def test_login(self):
newaapi = AppPixivAPI(bypass=True)
# newpapi = PixivAPI()
# self.assertIsNotNone(newaapi.login(_USERNAME, _PASSWORD))
credential = newaapi.login(refresh_token=_TOKEN)
self.assertIsNotNone(credential)
self.assertIsNotNone(credential.access_token)
self.assertIsNotNone(credential.refresh_token)
# self.assertIsNotNone(newpapi.login(_USERNAME, _PASSWORD))
def test_bypass(self):
newaapi = AppPixivAPI(bypass=True)
credential = newaapi.login(refresh_token=_TOKEN)
self.assertIsNotNone(credential)
self.assertIsNotNone(credential.access_token)
self.assertIsNotNone(credential.refresh_token)
detail = newaapi.user_detail(275527)
self.assertIsNotNone(detail)
self.assertIsNotNone(detail.user)
self.assertEqual(detail.user.id, 275527)
def test_bypass_2(self):
newaapi = AppPixivAPI(bypass=True, proxy="socks5://127.0.0.1:9011")
credential = newaapi.login(refresh_token=_TOKEN)
self.assertIsNotNone(credential)
self.assertIsNotNone(credential.access_token)
self.assertIsNotNone(credential.refresh_token)
detail = newaapi.user_detail(275527)
self.assertIsNotNone(detail)
self.assertIsNotNone(detail.user)
self.assertEqual(detail.user.id, 275527)
def test_socks_1(self):
newaapi = AppPixivAPI(proxy="socks5://127.0.0.1:9011")
credential = newaapi.login(refresh_token=_TOKEN)
self.assertIsNotNone(credential)
self.assertIsNotNone(credential.access_token)
self.assertIsNotNone(credential.refresh_token)
detail = newaapi.user_detail(275527)
self.assertIsNotNone(detail)
self.assertIsNotNone(detail.user)
self.assertEqual(detail.user.id, 275527)
def test_socks_2(self):
os.environ['ALL_PROXY'] = "socks5://127.0.0.1:9011"
newaapi = AppPixivAPI(env=True)
credential = newaapi.login(refresh_token=_TOKEN)
self.assertIsNotNone(credential)
self.assertIsNotNone(credential.access_token)
self.assertIsNotNone(credential.refresh_token)
detail = newaapi.user_detail(275527)
self.assertIsNotNone(detail)
self.assertIsNotNone(detail.user)
self.assertEqual(detail.user.id, 275527)
def test_new_illusts(self):
self.assertIsNotNone(aapi.illust_new())
def test_illust_1(self):
illust = aapi.illust_detail(59580629)
self.assertIsNotNone(illust)
self.assertIsNotNone(illust, illust)
self.assertEqual(illust.illust.id, 59580629)
self.assertIsNotNone(illust.illust.image_urls)
def test_illust_2(self):
self.assertIsNotNone(aapi.illust_comments(59580629))
def test_illust_3(self):
self.assertIsNotNone(aapi.ugoira_metadata(51815717))
def test_illust_4(self):
self.assertIsNotNone(aapi.illust_related(59580629))
def test_illust_5(self):
self.assertIsNotNone(aapi.illust_bookmark_detail(59580629))
def test_page(self):
self.assertIsNotNone(aapi.illust_recommended(
bookmark_illust_ids=[59580629], req_auth=False))
self.assertIsNotNone(aapi.illust_recommended(
bookmark_illust_ids=[59580629]))
json_result = aapi.illust_recommended(bookmark_illust_ids=[59580629])
# page down in some case
self.assertIsNotNone(aapi.parse_qs(json_result.next_url))
next_qs = aapi.parse_qs(json_result.next_url)
self.assertIsNotNone(aapi.illust_recommended(**next_qs))
def test_user_1(self):
self.assertIsNotNone(aapi.user_detail(275527))
def test_user_2(self):
self.assertIsNotNone(aapi.user_illusts(275527))
def test_user_3(self):