Ejemplo n.º 1
0
 def test_list_commands_converts_underscore_to_hyphen(
         self, mock_dir: mock.MagicMock):
     mock_dir.glob.return_value = [
         FakeFile("foo_bar.py"),
     ]
     commands = cli.TartufoCLI().list_commands(None)  # type: ignore
     self.assertEqual(commands, ["foo-bar"])
Ejemplo n.º 2
0
 def test_list_commands_excludes_init_py(self, mock_dir: mock.MagicMock):
     mock_dir.glob.return_value = [
         FakeFile("__init__.py"),
         FakeFile("foo.py"),
         FakeFile("bar.py"),
     ]
     commands = cli.TartufoCLI().list_commands(None)  # type: ignore
     self.assertNotIn("__init__", commands)
Ejemplo n.º 3
0
 def test_list_commands_strips_file_extensions(self,
                                               mock_dir: mock.MagicMock):
     mock_dir.glob.return_value = [
         FakeFile("foo.py"),
         FakeFile("bar.py"),
         FakeFile("baz.py"),
     ]
     commands = cli.TartufoCLI().list_commands(None)  # type: ignore
     self.assertEqual(commands, ["foo", "bar", "baz"])
Ejemplo n.º 4
0
 def test_list_commands_only_looks_at_python_files(
         self, mock_dir: mock.MagicMock):
     mock_dir.glob.return_value = [
         FakeFile("__init__.py"),
         FakeFile("foo.py"),
         FakeFile("bar.py"),
     ]
     cli.TartufoCLI().list_commands(None)  # type: ignore
     mock_dir.glob.assert_called_once_with("*.py")
Ejemplo n.º 5
0
 def test_get_command_fails_gracefully_on_invalid_commands(self):
     command = cli.TartufoCLI().get_command(None, "bar")  # type: ignore
     self.assertEqual(command, None)
Ejemplo n.º 6
0
 def test_get_command_returns_main_attribute_from_command_modules(self):
     command = cli.TartufoCLI().get_command(None, "foo")  # type: ignore
     self.assertEqual(command, command_foo.main)