示例#1
0
async def test_manager_reconnect_callback(patched_session, websocket_manager,
                                          xpub, mocker):
    patch_session(mocker, patched_session)
    await websocket_manager.start_websocket(
        auto_reconnect=False, reconnect_callback=reconnect_callback)
    assert test_queue2.qsize() == 1
    assert test_queue2.get() == "BTC"
示例#2
0
async def test_manager_start_websocket(patched_session, websocket_manager,
                                       xpub, mocker):
    websocket_manager.add_event_handler("new_transaction", new_tx_handler)
    patch_session(mocker, patched_session)
    await websocket_manager.start_websocket(auto_reconnect=False)
    assert test_queue.qsize() == 1
    assert test_queue.get() is True
示例#3
0
async def test_manager_bad_currency(patched_session_bad_currency,
                                    websocket_manager, xpub, mocker, caplog):
    websocket_manager.add_event_handler("new_transaction", new_tx_handler)
    patch_session(mocker, patched_session_bad_currency)
    await websocket_manager.start_websocket(auto_reconnect=False)
    assert test_queue.qsize() == 0
    assert "Received event for unsupported currency: test" in caplog.text
示例#4
0
    def test_good_captcha(self):
        """Good value for captcha allows login."""
        self.F.UserFactory.create(username="******", password="******")

        session_data = {}

        with patch_session(session_data):
            res = self.get()
            for i in range(6):
                res = res.forms["loginform"].submit()

            form = res.forms["loginform"]
            answer = session_data["auth_captcha_answer"]
            form["captcha"] = answer
            form["username"] = "******"
            form["password"] = "******"
            res = form.submit(status=302)

        self.assertRedirects(res, reverse("home"))
示例#5
0
    def test_bad_captcha(self):
        """Bad value for captcha fails login, even with correct user/pw."""
        self.F.UserFactory.create(username="******", password="******")

        session_data = {}

        with patch_session(session_data):
            res = self.get()
            for i in range(6):
                res = res.forms["loginform"].submit()

            form = res.forms["loginform"]
            answer = session_data["auth_captcha_answer"]
            form["captcha"] = answer + 1 # oops, wrong answer!
            form["username"] = "******"
            form["password"] = "******"
            res = form.submit(status=200)

        res.mustcontain("not the answer we were looking for")
示例#6
0
    def test_bad_captcha(self):
        """Bad value for captcha fails login, even with correct user/pw."""
        self.F.UserFactory.create(username="******", password="******")

        session_data = {}

        with patch_session(session_data):
            res = self.get()
            for i in range(6):
                res = res.forms["loginform"].submit()

            form = res.forms["loginform"]
            answer = session_data["auth_captcha_answer"]
            form["captcha"] = answer + 1  # oops, wrong answer!
            form["username"] = "******"
            form["password"] = "******"
            res = form.submit(status=200)

        res.mustcontain("not the answer we were looking for")
示例#7
0
    def test_good_captcha(self):
        """Good value for captcha allows login."""
        self.F.UserFactory.create(username="******", password="******")

        session_data = {}

        with patch_session(session_data):
            res = self.get()
            for i in range(6):
                res = res.forms["loginform"].submit()

            form = res.forms["loginform"]
            answer = session_data["auth_captcha_answer"]
            form["captcha"] = answer
            form["username"] = "******"
            form["password"] = "******"
            res = form.submit(status=302)

        self.assertRedirects(res, reverse("home"))
async def test_bad_json_reconnect_callback(patched_session_bad_json, btc_wallet, mocker):
    btc_wallet.add_event_handler("new_transaction", new_tx_handler)
    patch_session(mocker, patched_session_bad_json)
    await btc_wallet.start_websocket(auto_reconnect=False, reconnect_callback=lambda: test_queue.put(True))
    assert test_queue.qsize() == 1  # from reconnect_callback
    assert test_queue.get() is True
async def test_bad_json(patched_session_bad_json, btc_wallet, mocker):
    btc_wallet.add_event_handler("new_transaction", new_tx_handler)
    patch_session(mocker, patched_session_bad_json)
    await btc_wallet.start_websocket(auto_reconnect=False)
    assert test_queue.qsize() == 0