Example #1
0
    def test_require_phone_number_with_auto_resolving_warn(self):
        """Test require_phone_number with auto resolving security check when vk
        returns warning message like:
        'Incorrect numbers. You can repeat the attempt in 3 hours.'

        """
        auth_api = AuthAPI(phone_number='+123456789')
        html = get_fixture('require_phone_num_warn_resp.html')
        session_mock = mock.Mock()
        with self.assertRaises(VkPageWarningsError) as err:
            auth_api.require_phone_number(html=html, session=session_mock)
            self.assertIn(
                'Incorrect numbers. You can repeat the attempt in 3 hours',
                str(err))
Example #2
0
    def test_require_phone_number_with_auto_resolving(self):
        """Test require_phone_number with auto resolving security check.
        Expect that the method will parse given phone number and send
        confirmation request

        """
        auth_api = AuthAPI(phone_number='+123456789')
        html = get_fixture('require_phone_num_resp.html')
        session_mock = mock.Mock()
        auth_api.require_phone_number(html=html, session=session_mock)
        self.assertEqual(session_mock.post.call_count, 1)
        call = tuple(session_mock.post.call_args_list[0])[1]
        self.assertEqual(call['data']['act'], 'security_check')
        self.assertEqual(call['data']['code'], '567')
Example #3
0
    def test_require_phone_number(self):
        """Test require_phone_number with auto resolving security check.
        Expect that the method will parse given phone number and send
        confirmation request

        """
        auth_api = AuthAPI(phone_number='+123456789')
        html = get_fixture('require_phone_num_resp.html')
        session_mock = mock.Mock()
        auth_api.require_phone_number(html=html, session=session_mock)
        self.assertEqual(session_mock.post.call_count, 1)
        call = tuple(session_mock.post.call_args_list[0])[1]
        self.assertEqual(call['data']['act'], 'security_check')
        self.assertEqual(call['data']['code'], '567')
Example #4
0
    def test_require_phone_number_warn(self):
        """Test require_phone_number with auto resolving security check when vk
        returns warning message like:
        'Incorrect numbers. You can repeat the attempt in 3 hours.'

        """
        auth_api = AuthAPI(phone_number='+123456789')
        html = get_fixture('require_phone_num_warn_resp.html')
        session_mock = mock.Mock()
        with self.assertRaises(VkPageWarningsError) as err:
            auth_api.require_phone_number(html=html, session=session_mock)
            self.assertIn(
                'Incorrect numbers. You can repeat the attempt in 3 hours',
                str(err))
Example #5
0
def test_parse_captcha_html():
    html = get_fixture('captcha_resp.html')
    captcha_sid, captcha_url = utils.parse_captcha_html(
        html=html, response_url='http://test')
    assert captcha_sid == '600885884'
    assert captcha_url == 'http://test/captcha.php?s=0&sid=600885885'