Coverage for tests\test_norming.py: 100%

27 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2024-11-13 04:40 -0500

1import os 

2 

3import pytest 

4 

5import receptiviti 

6 

7receptiviti.readin_env() 

8 

9 

10@pytest.mark.skipif(os.getenv("RECEPTIVITI_KEY") is None, reason="no API key") 

11class TestStatus: 

12 def test_listing(self): 

13 res = receptiviti.norming() 

14 assert "custom/test" in res["name"].values 

15 

16 res = receptiviti.norming(name_only=True) 

17 assert "custom/test" in res 

18 

19 def test_single_status(self): 

20 res = receptiviti.norming("test") 

21 assert "custom/test" == res["name"] 

22 

23 def test_updating(self): 

24 norming_context = "short_text" 

25 receptiviti.norming(norming_context, delete=True) 

26 with pytest.warns(UserWarning, match="option invalid_option was not set"): 

27 receptiviti.norming(norming_context, options={"word_count_filter": 1, "invalid_option": 1}) 

28 with pytest.raises(RuntimeError, match="is not on record"): 

29 receptiviti.request("a text to score", version="v2", custom_context=norming_context) 

30 receptiviti.norming(norming_context, "new text to add") 

31 final_status = receptiviti.norming(norming_context) 

32 assert final_status["status"] == "completed" 

33 base_request = receptiviti.request("a new text to add", version="v2") 

34 self_normed_request = receptiviti.request("a new text to add", version="v2", custom_context=norming_context) 

35 assert not base_request.equals(self_normed_request)