def test_edit_note_success(self, mock_patch_note, mock_get_notes, mock_get_activity): mock_get_notes.return_value = [ PublicBarrierNote({ "id": 42, "text": "Existing note", "created_on": "2020-01-21T15:39:34.137208Z", "created_by": 1, }), ] url = reverse("barriers:public_barrier_detail", kwargs={"barrier_id": self.barrier["id"]}) url = f"{url}?edit-note=42" response = self.client.post(url, data={"note": "Edited note"}) assert response.status_code == HTTPStatus.FOUND mock_patch_note.assert_called_with(id=42, text="Edited note")
def test_delete_note_success(self, mock_delete_note, mock_get_notes, mock_get_activity): mock_get_notes.return_value = [ PublicBarrierNote({ "id": 71, "text": "Note", "created_on": "2020-01-21T15:39:34.137208Z", "created_by": 1, }), ] url = reverse( "barriers:public_barrier_detail", kwargs={"barrier_id": self.barrier["id"]} ) url = f"{url}?delete-note=71" response = self.client.post(url, data={"note_id": "71", "action": "delete-note"}) assert response.status_code == HTTPStatus.FOUND mock_delete_note.assert_called_with(id="71")
def get_notes(self, id, *args, **kwargs): return [ PublicBarrierNote(note) for note in self.client.get( f"{self.resource_name}/{id}/notes")["results"] ]