Best Python code snippet using molecule_python
test_main.py
Source:test_main.py
...26 27 test_parser_empty()28 tests main.parse_args() for no command29 30 test_command_create()31 tests main.command() for "create_order" command32 33 test_command_list()34 tests main.command() for "list_orders" command35 36 test_command_take()37 tests main.command() for "take_order" command38 39 test_command_empty()40 tests main.command() for no command41 42 """43 def test_parser_create(self):44 """45 Tests main.parse_args() for "create_order" command.46 """47 args = parse_args("create_order Sydney Auckland".split())48 self.assertEqual(args.command, "create_order")49 self.assertEqual(args.origin, "Sydney")50 self.assertEqual(args.destination, "Auckland")51 with self.assertRaises(SystemExit):52 args = parse_args("create_order".split())53 54 with self.assertRaises(SystemExit):55 args = parse_args("create_order Sydney".split())56 57 def test_parser_list(self):58 """59 Tests main.parse_args() for "list_orders" command.60 """61 args = parse_args("list_orders".split())62 self.assertEqual(args.command, "list_orders")63 with self.assertRaises(SystemExit):64 args = parse_args("list_orders foo".split())65 66 def test_parser_take(self):67 """68 Tests main.parse_args() for "take_order" command.69 70 """71 args = parse_args("take_order 7".split())72 self.assertEqual(args.command, "take_order")73 self.assertEqual(args.id, 7)74 with self.assertRaises(SystemExit):75 args = parse_args("take_order a".split())76 77 with self.assertRaises(SystemExit):78 args = parse_args("take_order".split())79 80 with self.assertRaises(SystemExit):81 args = parse_args("take_order 7 2".split())82 83 def test_parser_empty(self):84 """85 Tests main.parse_args() for no command.86 87 """88 args = parse_args("".split())89 self.assertEqual(args.command, None)90 def test_command_create(self):91 """92 Tests main.command() for "create_order" command.93 94 """95 args = parse_args("create_order Sydney Auckland".split())96 test_output = command(test_orders, "test.csv", args)97 self.assertEqual(test_output, "8")98 args = parse_args("create_order,Tsing Yi,Tuen Mun".split(",")) #Used "," as a separator in place of " " because origin and destination contain spaces.99 test_output = command(test_orders, "test.csv", args)100 self.assertEqual(test_output, "9")101 args = parse_args("create_order TST Central".split())102 test_output = command(test_orders, "test.csv", args)103 self.assertEqual(test_output, "10")104 ...
test_aux_command.py
Source:test_aux_command.py
...4from rastervision.rv_config import RVConfig5from rastervision.runner import CommandDefinition6import tests.mock as mk7class TestAuxCommand(mk.MockMixin, unittest.TestCase):8 def test_command_create(self):9 with RVConfig.get_tmp_dir() as tmp_dir:10 uris = [('one', '1'), ('two', '2')]11 cmd_conf = rv.CommandConfig.builder(mk.MOCK_AUX_COMMAND) \12 .with_config(uris=uris) \13 .with_root_uri(tmp_dir) \14 .build()15 cmd_conf = rv.command.CommandConfig.from_proto(cmd_conf.to_proto())16 cmd = cmd_conf.create_command()17 self.assertTrue(cmd, mk.MockAuxCommand)18 cmd.run(tmp_dir)19 self.assertTrue(cmd.mock.run.called)20 def test_command_from_experiment(self):21 with RVConfig.get_tmp_dir() as tmp_dir:22 uris = [('one', '1'), ('two', '2'), ('three', '3'), ('four', '4')]...
test_command.py
Source:test_command.py
...5import pytest6import concurrency.management.commands.triggers as command7logger = logging.getLogger(__name__)8@pytest.mark.django_db9def test_command_create(monkeypatch):10 out = io.StringIO()11 mock_create = Mock()12 mock_create.return_value = {'default': [['model', 'field', 'trigger']]}13 monkeypatch.setattr(command, 'create_triggers', mock_create)14 call_command('triggers', 'create', stdout=out)15 out.seek(0)16 output = out.read()17 assert output.find('Created trigger for field') > 018 assert mock_create.call_count == 119@pytest.mark.django_db20def test_command_create_db(monkeypatch):21 out = io.StringIO()22 mock_create = Mock()23 mock_create.return_value = {'default': [['model', 'field', 'trigger']]}...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!