Coverage for tests\test_status.py: 100%

22 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2024-09-30 12:52 -0400

1import os 

2from contextlib import redirect_stdout 

3from io import StringIO 

4 

5import pytest 

6 

7import receptiviti 

8 

9receptiviti.readin_env() 

10 

11 

12class TestStatus: 

13 def test_unrecognized_key(self): 

14 res = receptiviti.status(key="123", secret="123") 

15 assert res.json()["code"] == 1411 

16 

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" 

22 

23 def test_invalid_url(self): 

24 with pytest.raises(TypeError): 

25 receptiviti.status("localhost") 

26 

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