Exemplo n.º 1
0
def test_reply():
    comment = Mock()
    reddit.reply(comment, "foo")
    comment.reply.assert_called_with("foo")
    ex = RedditAPIException(
        [RedditErrorItem("a", "b"),
         RedditErrorItem("c", "d")])
    comment.reply.side_effect = ex
    with pytest.raises(RedditAPIException):
        reddit.reply(comment, "bar")
    ex.items[-1].error_type = "DELETED_COMMENT"
    reddit.reply(comment, "bar")
Exemplo n.º 2
0
 def test_repr(self):
     error = RedditErrorItem("BAD_SOMETHING", "invalid something",
                             "some_field")
     assert (
         repr(error) ==
         "RedditErrorItem(error_type='BAD_SOMETHING', message='invalid something', field='some_field')"
     )
Exemplo n.º 3
0
 def test_items(self):
     container = RedditAPIException([
         ["BAD_SOMETHING", "invalid something", "some_field"],
         RedditErrorItem("BAD_SOMETHING", "invalid something",
                         "some_field"),
     ])
     for exception in container.items:
         assert isinstance(exception, RedditErrorItem)
Exemplo n.º 4
0
 def test_str(self):
     error = RedditErrorItem("BAD_SOMETHING", "invalid something",
                             "some_field")
     assert (str(error) ==
             "BAD_SOMETHING: 'invalid something' on field 'some_field'")
Exemplo n.º 5
0
 def test_property(self):
     error = RedditErrorItem("BAD_SOMETHING", "invalid something",
                             "some_field")
     assert (error.error_message ==
             "BAD_SOMETHING: 'invalid something' on field 'some_field'")
Exemplo n.º 6
0
 def test_equality(self):
     resp = ["BAD_SOMETHING", "invalid something", "some_field"]
     error = RedditErrorItem(*resp)
     error2 = RedditErrorItem(*resp)
     assert error == error2
     assert error != 0