Skip to content

Commit

Permalink
test: test delete with command line
Browse files Browse the repository at this point in the history
  • Loading branch information
evanp committed Nov 20, 2023
1 parent a4bb517 commit 9c6ffd8
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions tests/test_delete.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import unittest
from unittest.mock import patch, mock_open, MagicMock
from ap.commands.delete import DeleteCommand
from ap.main import run_command
from argparse import Namespace
import io
import sys
Expand Down Expand Up @@ -44,14 +44,12 @@ def tearDown(self):
def test_delete_with_confirmation(
self, mock_input, mock_requests_get, mock_oauth_post, mock_file
):
args = Namespace(id=NOTE_ID, force=False)
delete_cmd = DeleteCommand(args)

mock_oauth_post.return_value = MagicMock(
status_code=200, json=lambda: {"success": True}
)

delete_cmd.run()
run_command(["delete", NOTE_ID], {})

# Assertions
self.assertEqual(mock_requests_get.call_count, 2)
Expand All @@ -66,14 +64,12 @@ def test_delete_with_confirmation(
def test_delete_with_force(
self, mock_input, mock_requests_get, mock_oauth_post, mock_file
):
args = Namespace(id=NOTE_ID, force=True)
delete_cmd = DeleteCommand(args)

mock_oauth_post.return_value = MagicMock(
status_code=200, json=lambda: {"success": True}
)

delete_cmd.run()
run_command(["delete", "--force", NOTE_ID], {})

# Assertions
self.assertEqual(mock_requests_get.call_count, 2)
Expand Down

0 comments on commit 9c6ffd8

Please sign in to comment.