Ejemplo n.º 1
0
def test_cli_usage():
    # Test the -h
    with pytest.raises(SystemExit) as excinfo:
        cli.main("-h")
        assert excinfo.code == 0
    with pytest.raises(SystemExit) as excinfo:
        cli.main("--version")
        assert excinfo.code == 0
Ejemplo n.º 2
0
def facility_sync(syncserver, syncfacilityid):
    pid = os.fork()
    if pid == 0:
        main([
            "manage", "sync", "--baseurl", syncserver, "--facility",
            syncfacilityid, "--verbosity", "3"
        ])
    else:
        os.waitpid(pid, 0)
Ejemplo n.º 3
0
def start_django():

    # remove this after Kolibri no longer needs it
    if sys.version[0] == "2":
        reload(sys)
        sys.setdefaultencoding("utf8")

    logging.info("Starting server...")
    from kolibri.utils.cli import main

    main(["start", "--foreground", "--port=5000"])
Ejemplo n.º 4
0
    def test_do_rollover(self):
        archive_dir = os.path.join(os.environ["KOLIBRI_HOME"], "logs",
                                   "archive")
        orig_value = settings.LOGGING["handlers"]["file"]["when"]

        # Temporarily set the rotation time of the log file to be every second
        settings.LOGGING["handlers"]["file"]["when"] = "s"
        # make sure that kolibri will be running for more than one second
        cli.main(["--skipupdate", "manage", "help"])
        sleep(1)
        cli.main(["--skipupdate", "manage", "help"])
        # change back to the original rotation time
        settings.LOGGING["handlers"]["file"]["when"] = orig_value

        self.assertNotEqual(os.listdir(archive_dir), [])
Ejemplo n.º 5
0
 def test_content_dir_not_writable(self, access_mock, logging_mock):
     with self.assertRaises(SystemExit):
         cli.main(["start"])
         logging_mock.assert_called()
Ejemplo n.º 6
0
 def test_old_log_file_exists(self, path_exists_mock, move_mock, initialize_mock):
     cli.main(["language", "setdefault", "en"])
     # Check if the number of calls to shutil.move equals to the number of times
     # os.path.exists returns True
     self.assertEqual(move_mock.call_count, 2)
Ejemplo n.º 7
0
 def test_port_occupied(self, status_mock, portend_mock, logging_mock):
     status_mock.side_effect = NotRunning("Kolibri not running")
     portend_mock.side_effect = portend.Timeout
     with self.assertRaises(SystemExit):
         cli.main(["start"])
         logging_mock.assert_called()
Ejemplo n.º 8
0
 def test_content_dir_dne(self, logging_mock, version_file=None, orig_version=None):
     version_file = cli.version_file()
     open(version_file, "w").write(orig_version)
     with self.assertRaises(SystemExit):
         cli.main(["start"])
         logging_mock.assert_called()
Ejemplo n.º 9
0
from __future__ import absolute_import, print_function, unicode_literals

import sys

if __name__ == "__main__":

    from kolibri.utils.cli import main
    main(args=sys.argv[1:])
Ejemplo n.º 10
0
 def test_other_kolibri_running(self, status_mock, logging_mock):
     with self.assertRaises(SystemExit):
         cli.main(["start"])
         logging_mock.assert_called()
Ejemplo n.º 11
0
 def test_plugin_cli(self):
     main(("plugin", "kolibri.plugins.example_plugin", "enable"))
     main(("plugin", "kolibri.plugins.example_plugin", "disable"))
Ejemplo n.º 12
0
 def test_port_occupied(self, status_mock, socket_mock, logging_mock):
     status_mock.side_effect = NotRunning('Kolibri not running')
     socket_mock.return_value.bind.side_effect = socket.error
     with self.assertRaises(SystemExit):
         cli.main({'start': True})
         logging_mock.assert_called()
Ejemplo n.º 13
0
 def test_content_dir_dne(self, path_mock, logging_mock):
     with self.assertRaises(SystemExit):
         cli.main({'start': True})
         logging_mock.assert_called()
Ejemplo n.º 14
0
 def test_cli(self):
     logger.debug("This is a unit test in the main Kolibri app space")
     # Test the -h
     with self.assertRaises(SystemExit):
         main("-h")
Ejemplo n.º 15
0
 def test_content_dir_writable(self, path_exists_mock, access_mock, logging_mock):
     with self.assertRaises(SystemExit):
         cli.main({'start': True})
         logging_mock.assert_called
Ejemplo n.º 16
0
def test_cli_usage():
    # Test the -h
    with pytest.raises(SystemExit, code=0):
        cli.main("-h")
    with pytest.raises(SystemExit, code=0):
        cli.main("--version")
Ejemplo n.º 17
0
def test_cli_usage():
    # Test the -h
    with pytest.raises(SystemExit, code=0):
        cli.main("-h")
    with pytest.raises(SystemExit, code=0):
        cli.main("--version")
Ejemplo n.º 18
0
 def test_cli(self):
     logger.debug("This is a unit test in the main Kolibri app space")
     # Test the -h
     with self.assertRaises(SystemExit):
         main("-h")
Ejemplo n.º 19
0
 def test_content_dir_dne(self, logging_mock, get_version):
     with self.assertRaises(SystemExit):
         cli.main(["manage"])
         logging_mock.assert_called()
Ejemplo n.º 20
0
from __future__ import absolute_import
from __future__ import print_function
from __future__ import unicode_literals

import sys

if __name__ == "__main__":

    from kolibri.utils.cli import main

    main(args=sys.argv[1:])
Ejemplo n.º 21
0
 def test_plugin_cli(self):
     main(("plugin", "kolibri.plugins.example_plugin", "enable"))
     main(("plugin", "kolibri.plugins.example_plugin", "disable"))