def test_delete_passes(self, mock_login, mock_delete, mock_list_tags): """ Test .delete() works """ mock_login.return_value = self.account_id mock_response = Mock(spec=requests.Response) mock_response.status_code = 200 mock_response.ok = True mock_delete.return_value = mock_response mock_list_tags.return_value = [ { 'id': '19dede15-118b-467f-bfe9-e9c771d7cc2c', 'scheduled_query_id': '00000000-0000-469c-0000-000000000000' } ] alert = AnomalyAlert(self.username, self.password) alert.delete('19dede15-118b-467f-bfe9-e9c771d7cc2c') mock_delete.assert_has_calls( [ call( url='https://logentries.com/rest/{account_id}/api/tags/{tag}'.format( account_id=self.account_id, tag='19dede15-118b-467f-bfe9-e9c771d7cc2c' ) ), call( url='https://logentries.com/rest/{account_id}/api/scheduled_queries/{query_id}'.format( account_id=self.account_id, query_id='00000000-0000-469c-0000-000000000000' ) ), ] )
def test_delete_doesnt_exist(self, mock_login, mock_delete, mock_list_tags): """ Test .delete() where key doesn't exist """ mock_login.return_value = self.account_id mock_response = Mock(spec=requests.Response) mock_response.status_code = 200 mock_response.ok = True mock_delete.return_value = mock_response mock_list_tags.return_value = [ { 'id': 'not-a-match', 'scheduled_query_id': '00000000-0000-469c-0000-000000000000' } ] alert = AnomalyAlert(self.username, self.password) alert.delete('19dede15-118b-467f-bfe9-e9c771d7cc2c') self.assertFalse(mock_delete.called)