Ejemplo n.º 1
0
    def test_cmd_list_if_invalid_command_given(self):
        self._replace_stdout_with_stringio()
        ret = admin.main(["this is not a valid command"])

        self.assertEquals(ret, False)
        stdout = sys.stdout.getvalue()
        self._check_cmd_list(stdout)
Ejemplo n.º 2
0
    def test_main(self):
        saved_commands = admin.commands

        def restore_commands():
            admin.commands = saved_commands

        testcmdclass = mock.Mock()
        testcmd = mock.Mock()
        testcmdclass.return_value = testcmd

        admin.commands = {"Test": testcmdclass}
        self.addCleanup(restore_commands)

        admin.main(["Test", "arg2", "arg3"])

        testcmd.init.assert_called_with(["arg2", "arg3"])
        testcmd.assert_called_with()
Ejemplo n.º 3
0
    def test_unauthorized_error(self):
        self._replace_stdout_with_stringio()
        self._define_test_cmd()

        ret = admin.main(["Foo", "-r"])

        self.assertFalse(ret)
        self.assertEquals(sys.stdout.getvalue(), "Action not permitted\n")
Ejemplo n.º 4
0
 def test_command_long_option(self):
     self._define_test_cmd()
     self.succesful = False
     admin.main(["Foo", "--mark_succesful"])
     self.assertTrue(self.succesful)
Ejemplo n.º 5
0
 def test_command_short_option(self):
     self._define_test_cmd()
     self.succesful = False
     admin.main(["Foo", "-m"])
     self.assertTrue(self.succesful)