예제 #1
0
파일: lib_test.py 프로젝트: iCodeIN/ugoira
    def case2():
        """
        original head - good
        original get - bad
        common head - bad
        common get - not reached
        """
        responses.reset()
        responses.add(
            **{
                'method': responses.GET,
                'url': get_metadata_url(ugoira_id),
                'body': meta_body,
                'content_type': 'application/json',
                'status': 200,
                'match_querystring': True,
            })
        responses.add(**{
            'method': responses.HEAD,
            'url': big_zip_url,
            'status': 200,
        })
        responses.add(**{
            'method': responses.GET,
            'url': big_zip_url,
            'status': 403,
        })
        responses.add(**{
            'method': responses.HEAD,
            'url': small_zip_url,
            'status': 403,
        })

        with pytest.raises(PixivError):
            download_ugoira_zip(ugoira_id)
예제 #2
0
    def test():
        responses.reset()
        responses.add(
            **{
                'method': responses.GET,
                'url': 'http://www.pixiv.net/member_illust.php'
                '?mode=medium&illust_id=53239740',
                'body': fx_ugoira_body,
                'content_type': 'text/html; charset=utf-8',
                'status': 200,
                'match_querystring': True,
            })
        responses.add(
            **{
                'method': responses.HEAD,
                'url': 'http://i1.pixiv.net/img-zip-ugoira/img/'
                '2015/10/27/22/10/14/53239740_ugoira600x600.zip',
                'status': 200,
            })
        responses.add(
            **{
                'method': responses.GET,
                'url': 'http://i1.pixiv.net/img-zip-ugoira/img/'
                '2015/10/27/22/10/14/53239740_ugoira600x600.zip',
                'status': 403,
            })

        with pytest.raises(PixivError):
            download_ugoira_zip(53239740)
예제 #3
0
파일: lib_test.py 프로젝트: iCodeIN/ugoira
    def test():
        responses.reset()
        responses.add(
            **{
                'method': responses.GET,
                'url': get_metadata_url(ugoira_id),
                'body': error_meta_body,
                'content_type': 'application/json',
                'status': 200,
                'match_querystring': True,
            })

        with pytest.raises(PixivError):
            download_ugoira_zip(ugoira_id)
예제 #4
0
    def test():
        responses.reset()
        responses.add(
            **{
                'method': responses.GET,
                'url': get_illust_url(ugoira_id),
                'body': fx_ugoira_body,
                'content_type': 'text/html; charset=utf-8',
                'status': 200,
                'match_querystring': True,
            })
        responses.add(**{
            'method': responses.HEAD,
            'url': zip_url,
            'status': 200,
        })
        responses.add(
            **{
                'method': responses.GET,
                'url': zip_url,
                'body': fx_ugoira_zip,
                'content_type': 'application/zip',
                'status': 200,
            })

        data, frames = download_ugoira_zip(ugoira_id)
        assert data == fx_ugoira_zip
예제 #5
0
파일: lib_test.py 프로젝트: iCodeIN/ugoira
    def case1():
        """
        original head - good
        original get - good
        common head - not reached
        common get - not reached
        """
        responses.reset()
        responses.add(
            **{
                'method': responses.GET,
                'url': get_metadata_url(ugoira_id),
                'body': meta_body,
                'content_type': 'application/json',
                'status': 200,
                'match_querystring': True,
            })
        responses.add(**{
            'method': responses.HEAD,
            'url': big_zip_url,
            'status': 200,
        })
        responses.add(
            **{
                'method': responses.GET,
                'url': big_zip_url,
                'body': big_image_zip,
                'content_type': 'application/zip',
                'status': 200,
            })

        data, frames = download_ugoira_zip(ugoira_id)
        assert data == big_image_zip
예제 #6
0
    def test():
        responses.reset()
        responses.add(
            **{
                'method': responses.GET,
                'url': get_illust_url(ugoira_id),
                'body': fx_ugoira_body,
                'content_type': 'text/html; charset=utf-8',
                'status': 200,
                'match_querystring': True,
            })
        responses.add(**{
            'method': responses.HEAD,
            'url': zip_url,
            'status': 403,
        })

        with pytest.raises(PixivError):
            download_ugoira_zip(ugoira_id)
예제 #7
0
    def _downloadUgoiraPost(self, illustId):
        """Downloads an ugoira post"""

        import ugoira.lib as Ugoira
        # this incorporates some functions from the ugoira library
        # found at https://github.com/item4/ugoira

        # get ugoira file
        print("Downloading ugoira and saving to GIF format")
        ugoiraData, frames = Ugoira.download_ugoira_zip(int(illustId))

        # convert to GIF and save to path
        Ugoira.make_gif(self._getFolderPath() + "{}.gif".format(str(illustId)),
                        ugoiraData, frames)

        print("File saved to {}.gif".format(self._getFolderPath() + illustId))