commit 33471f2ee1c59eec3e6ca48d18c4cbb1e4c04952
parent e3ae0b5dcc13cf280f8cc79dbd8263acd98b0508
Author: Carlosokumu <carlosokumu254@gmail.com>
Date: Wed, 10 Sep 2025 17:41:00 +0300
test edit command
Diffstat:
1 file changed, 29 insertions(+), 7 deletions(-)
diff --git a/tests/cmd/test_args_parser.py b/tests/cmd/test_args_parser.py
@@ -1,5 +1,5 @@
import unittest
-from unittest.mock import patch
+from unittest.mock import MagicMock, patch
import argparse
from ungana.cmd.args_parser import ArgsParser
@@ -7,31 +7,53 @@ from ungana.cmd.args_parser import ArgsParser
class TestArgsParser(unittest.TestCase):
def setUp(self):
- self.parser = ArgsParser()
+ self.args_parser = ArgsParser()
+ self.mock_manager = self.args_parser.ical_manager
def test_ensure_no_multiline_input_valid(self):
- result = self.parser._ensure_no_multiline_input("foo bar")
+ result = self.args_parser._ensure_no_multiline_input("foo bar")
self.assertEqual(result, "foo bar")
def test_ensure_no_multiline_input_invalid(self):
with self.assertRaises(argparse.ArgumentTypeError):
- self.parser._ensure_no_multiline_input("bad\nline")
+ self.args_parser._ensure_no_multiline_input("bad\nline")
def test_process_contact_arg_with_params(self):
- value, params = self.parser._process_contact_arg("Go pher|ALTREP=mailto:gophers@go.org")
+ value, params = self.args_parser._process_contact_arg("Go pher|ALTREP=mailto:gophers@go.org")
self.assertEqual(value, "Go pher")
self.assertEqual(params, {"ALTREP": "mailto:gophers@go.org"})
def test_process_contact_arg_simple(self):
- value, params = self.parser._process_contact_arg("gophers@go.org")
+ value, params = self.args_parser._process_contact_arg("gophers@go.org")
self.assertEqual(value, "gophers@go.org")
self.assertEqual(params, {})
@patch("sys.argv", ["prog", "create", "-s", "Gophers Meetup", "--start", "2025-09-06 10:00", "-d", "Gophers yearly meetup", "-l", "Gopher Confrence Hall", "-o", "events@gophers.com"])
def test_parse_args_create_command(self):
- args = self.parser.parse_args()
+ args = self.args_parser.parse_args()
self.assertEqual(args.command, "create")
self.assertEqual(args.summary, "Gophers Meetup")
self.assertEqual(args.location, "Gopher Confrence Hall")
+
+
+ @patch("sys.argv", ["prog", "edit","calendar.ics","-s", "Updated Gophers Meetup","-l", "Updated Conference Hall","-o", "neworganizer@gophers.com","--description", "Updated description"])
+ def test_parse_args_edit_command(self):
+ args = self.args_parser.parse_args()
+ self.assertEqual(args.command, "edit")
+ self.assertEqual(args.ics_file, "calendar.ics")
+ self.assertEqual(args.summary, "Updated Gophers Meetup")
+ self.assertEqual(args.location, "Updated Conference Hall")
+ self.assertEqual(args.organizer, "neworganizer@gophers.com")
+ self.assertEqual(args.description, "Updated description")
+
+
+ @patch("sys.argv", ["prog", "edit", "calendar.ics","--host", "http://host.com","--venue", "http://venue.com","--presenter", "http://presenter.com"])
+ def test_parse_args_edit_with_presenter_host_venue(self):
+ args = self.args_parser.parse_args()
+ self.assertEqual(args.host, "http://host.com")
+ self.assertEqual(args.venue, "http://venue.com")
+ self.assertEqual(args.presenter, "http://presenter.com")
+
+