(self, reddit)
| 18 | assert reddit._objector.objectify(data=None) is None |
| 19 | |
| 20 | def test_parse_error(self, reddit): |
| 21 | objector = reddit._objector |
| 22 | assert objector.parse_error({}) is None |
| 23 | assert objector.parse_error([]) is None |
| 24 | assert objector.parse_error({"asdf": 1}) is None |
| 25 | |
| 26 | error_response = {"json": {"errors": [["USER_REQUIRED", "Please log in to do that.", None]]}} |
| 27 | error = objector.parse_error(error_response) |
| 28 | assert isinstance(error, RedditAPIException) |
| 29 | |
| 30 | error_response = {"json": {"errors": []}} |
| 31 | with pytest.raises(ClientException): |
| 32 | objector.parse_error(error_response) |
| 33 | |
| 34 | error_response = { |
| 35 | "json": { |
| 36 | "errors": [ |
| 37 | ["USER_REQUIRED", "Please log in to do that.", None], |
| 38 | ["NO_SUBJECT", "please enter a subject", "subject"], |
| 39 | ] |
| 40 | } |
| 41 | } |
| 42 | assert isinstance(objector.parse_error(error_response), RedditAPIException) |
nothing calls this directly
no test coverage detected