Esempio n. 1
0
    def test_authenticate_success(self):
        responses.add(responses.POST,
                      Constants.URL['sandbox'] + '/authorize',
                      content_type='application/json',
                      status=200,
                      json=TestGerencianet.auth_success)

        endpoints = Gerencianet({'client_id': 'cid', 'client_secret': 'csec'})
        endpoints.authenticate()

        assert endpoints.token == TestGerencianet.auth_success
    def test_authenticate_failure(self):
        responses.add(
            responses.POST, Constants.URL["sandbox"] + "/authorize", content_type="application/json", status=401
        )

        endpoints = Gerencianet({"client_id": "cid", "client_secret": "csec"})

        with pytest.raises(UnauthorizedError) as raised:
            endpoints.authenticate()

        assert "401" in str(raised)
Esempio n. 3
0
    def test_authenticate_failure(self):
        responses.add(responses.POST,
                      Constants.URL['sandbox'] + '/authorize',
                      content_type='application/json',
                      status=401)

        endpoints = Gerencianet({'client_id': 'cid', 'client_secret': 'csec'})

        with pytest.raises(UnauthorizedError) as raised:
            endpoints.authenticate()

        assert '401' in str(raised)
    def test_authenticate_success(self):
        responses.add(
            responses.POST,
            Constants.URL["sandbox"] + "/authorize",
            content_type="application/json",
            status=200,
            json=TestGerencianet.auth_success,
        )

        endpoints = Gerencianet({"client_id": "cid", "client_secret": "csec"})
        endpoints.authenticate()

        assert endpoints.token == TestGerencianet.auth_success