Esempio n. 1
0
    def test():
        responses.reset()
        responses.add(**{
            'method': responses.GET,
            'url': 'http://www.pixiv.net/',
            'body': 'dead',
            'status': 404,
        })

        with pytest.raises(PixivError):
            login(*fx_valid_id_pw)
Esempio n. 2
0
 def test():
     responses.reset()
     responses.add(**{
         'method': responses.GET,
         'url': 'http://www.pixiv.net/',
         'body': 'Just touch, Do not access it really.'
                 ' Because they block us.',
         'content_type': 'text/html; charset=utf-8',
         'status': 200,
     })
     with pytest.raises(PixivError):
         login(*fx_too_long_id_pw)
Esempio n. 3
0
def test_login_miss_password():
    """Test :func:`ugoira.lib.login` try, but missing password and raise
    :exception:`ugoira.lib.PixivError`.

    """

    id = None
    password = None
    with pytest.raises(PixivError):
        login(id, password)

    id = 'item4'
    with pytest.raises(PixivError):
        login(id, password)
Esempio n. 4
0
    def test():
        responses.reset()
        responses.add(**{
            'method': responses.GET,
            'url': 'http://www.pixiv.net/',
            'body': 'Just touch, Do not access it really.'
                    ' Because they block us.',
            'content_type': 'text/html; charset=utf-8',
            'status': 200,
        })
        responses.add(**{
            'method': responses.POST,
            'url': 'https://www.pixiv.net/login.php',
            'body': 'Just touch, Do not access it really.'
                    ' Because they block us.',
            'content_type': 'text/html; charset=utf-8',
            'status': 301,
            'adding_headers': {
                'Location': 'http://example.com/'
            },
        })
        responses.add(**{
            'method': responses.GET,
            'url': 'http://example.com/',
            'body': 'Just touch, Do not access it really.'
                    ' Because they block us.',
            'content_type': 'text/html; charset=utf-8',
            'status': 200,
        })

        assert not login(*fx_invalid_id_pw)
Esempio n. 5
0
    def test():
        responses.reset()
        responses.add(**{
            'method': responses.GET,
            'url': 'http://www.pixiv.net/',
            'body': 'pass',
            'status': 200,
        })
        responses.add(**{
            'method': responses.POST,
            'url': 'https://www.pixiv.net/login.php',
            'body': ConnectionError('dead'),
            'status': 500,
        })

        with pytest.raises(PixivError):
            login(*fx_valid_id_pw)
Esempio n. 6
0
    def test():
        responses.reset()
        responses.add(**{
            'method': responses.GET,
            'url': 'http://www.pixiv.net/',
            'body': 'pass',
            'status': 200,
        })
        responses.add(**{
            'method': responses.POST,
            'url': 'https://www.pixiv.net/login.php',
            'body': 'dead',
            'content_type': 'text/html; charset=utf-8',
            'status': 404,
        })

        with pytest.raises(PixivError):
            login(*fx_valid_id_pw)
Esempio n. 7
0
    def test():
        responses.reset()
        responses.add(**{
            'method': responses.GET,
            'url': 'http://www.pixiv.net/',
            'body': 'Just touch, Do not access it really.'
                    ' Because they block us.',
            'content_type': 'text/html; charset=utf-8',
            'status': 200,
        })
        responses.add(**{
            'method': responses.POST,
            'url': 'https://www.pixiv.net/login.php',
            'body': '誤入力が続いたため、アカウントのロックを行いました。'
                    'しばらく経ってからログインをお試しください。',
            'content_type': 'text/html; charset=utf-8',
            'status': 200,
        })

        with pytest.raises(PixivError):
            login(*fx_invalid_id_pw)