Exemplo n.º 1
0
 def test_add_argument(self, m_parser):
     """add_argument() wraps argparse.ArgumentParser.add_argument()
     """
     cli = CommandLineInterface("test")
     cli.parser = m_parser
     cli.add_argument(
         "--yesterday",
         action="store_true",
         help="Download forecast files for previous day's date.",
     )
     m_parser.add_argument.assert_called_once_with(
         "--yesterday",
         action="store_true",
         help="Download forecast files for previous day's date.",
     )
Exemplo n.º 2
0
 def test_config_file_arg(self):
     cli = CommandLineInterface("test")
     cli.build_parser()
     assert cli.parser._positionals._actions[1].dest == "config_file"
Exemplo n.º 3
0
 def test_usage(self):
     cli = CommandLineInterface("test")
     cli.build_parser()
     assert cli.parser.prog == "python -m nowcast.test"
Exemplo n.º 4
0
 def test_no_help(self):
     cli = CommandLineInterface("test")
     cli.build_parser(add_help=False)
     assert not isinstance(cli.parser._optionals._actions[0], argparse._HelpAction)
Exemplo n.º 5
0
 def test_description(self):
     cli = CommandLineInterface("test", description="foo bar baz")
     assert cli.description == "foo bar baz"
Exemplo n.º 6
0
 def test_parser(self):
     cli = CommandLineInterface("test")
     assert cli.parser is None
Exemplo n.º 7
0
 def test_package(self):
     cli = CommandLineInterface("test", package="foo")
     assert cli.package == "foo"
Exemplo n.º 8
0
 def test_default_no_description(self):
     cli = CommandLineInterface("test")
     assert cli.description is None
Exemplo n.º 9
0
 def test_module_name(self):
     cli = CommandLineInterface("test")
     assert cli.module_name == "test"
Exemplo n.º 10
0
 def test_default_package(self):
     cli = CommandLineInterface("test")
     assert cli.package == "nowcast"
Exemplo n.º 11
0
 def test_arrow_date_parse_erroe(self):
     cli = CommandLineInterface("test")
     with pytest.raises(argparse.ArgumentTypeError):
         cli.arrow_date("205-7-261")
Exemplo n.º 12
0
 def test_arrow_date(self):
     cli = CommandLineInterface("test")
     arw = cli.arrow_date("2016-09-22")
     expected = arrow.get(datetime(2016, 9, 22, 0, 0, 0), "utc")
     assert arw == expected
Exemplo n.º 13
0
 def test_help(self):
     cli = CommandLineInterface("test")
     cli.build_parser()
     cli.add_date_option("--test-date", arrow.get("2016-09-22"), "Help message.")
     expected = "Help message. Use YYYY-MM-DD format. Defaults to 2016-09-22."
     assert cli.parser._actions[2].help == expected
Exemplo n.º 14
0
 def test_default(self):
     cli = CommandLineInterface("test")
     cli.build_parser()
     cli.add_date_option("--test-date", arrow.get("2016-09-22"), "help")
     assert cli.parser._actions[2].default == arrow.get("2016-09-22")
Exemplo n.º 15
0
 def test_option_name(self):
     cli = CommandLineInterface("test")
     cli.build_parser()
     cli.add_date_option("--test-date", arrow.get("2016-09-22"), "help")
     assert cli.parser._actions[2].option_strings == ["--test-date"]