def test_delete(self, mock_url, mock_request): mock_url.__get__ = mock.Mock(return_value='https://www.yikyak.com/') message = Message() message.delete() # Expected API call method = 'DELETE' url = 'https://www.yikyak.com/' params = { 'userLat': 0, 'userLong': 0, } mock_request.assert_called_with(method, url, params=params)
def test_report_other(self, mock_url, mock_request): """ Assert reporting for 'Other' makes the correct API call """ mock_url.__get__ = mock.Mock(return_value='https://www.yikyak.com/') message = Message() message.report(0, block=False) # Expected API call method = 'PUT' url = 'https://www.yikyak.com/report' params = { 'userLat': 0, 'userLong': 0, } json = { 'block': False, 'reason': 'Other', } mock_request.assert_called_with(method, url, params=params, json=json)
def test_message_url(self): message = Message() with self.assertRaises(NotImplementedError): message.message_url
def test_upvote(self, mock_vote): message = Message() message.upvote() mock_vote.assert_called_with('upvote')
def test_downvote(self, mock_vote): message = Message() message.downvote() mock_vote.assert_called_with('downvote')
def test_vote_invalid(self): message = Message() with self.assertRaises(AssertionError): message._vote('qwerty')