Coverage for tests\test_status.py: 100%
22 statements
« prev ^ index » next coverage.py v7.3.1, created at 2023-09-18 15:57 -0400
« prev ^ index » next coverage.py v7.3.1, created at 2023-09-18 15:57 -0400
1import os
2from contextlib import redirect_stdout
3from io import StringIO
5import pytest
7import receptiviti
9receptiviti.readin_env()
12class TestStatus:
13 def test_unrecognized_key(self):
14 res = receptiviti.status(key="123", secret="123")
15 assert res.json()["code"] == 1411
17 def test_unrecognized_key_message(self):
18 with redirect_stdout(StringIO()) as out:
19 receptiviti.status(key="123", secret="123")
20 message = out.getvalue()
21 assert message.split("\n")[0] == "Status: ERROR"
23 def test_invalid_url(self):
24 with pytest.raises(TypeError):
25 receptiviti.status("localhost")
27 @pytest.mark.skipif(condition=os.getenv("RECEPTIVITI_KEY") is None, reason="no API key")
28 def test_key_works(self):
29 res = receptiviti.status()
30 assert res.status_code == 200