Ejemplo n.º 1
0
def given_runserver_exists(project):
    config = utils.get_config(True)

    if not os.path.exists(os.path.join(utils.get_projects_dir(), project)):
        os.makedirs(os.path.join(utils.get_projects_dir(), project))

    os.mkdir(
        os.path.join(utils.get_projects_dir(), project,
                     os.path.dirname(config["serverBinFilename"])))
    open(
        os.path.join(utils.get_projects_dir(), project,
                     config["serverBinFilename"]), "wb").close()
Ejemplo n.º 2
0
    def test_update_clone_projects(self, mock_path_exists):
        # WHEN
        main(["main.py", "--init", "update-projects"])

        # THEN
        self.assertEqual(self.mock_git_repo.clone_from.call_count, 2)
        self.mock_subprocess_call.assert_any_call([
            "make", "install", "-C",
            os.path.join(utils.get_projects_dir(), "platform")
        ])
        self.mock_subprocess_call.assert_any_call([
            "make", "install", "-C",
            os.path.join(utils.get_projects_dir(), "frontend")
        ])
Ejemplo n.º 3
0
def given_python_version_file_exists(version='1.2.2'):
    config = utils.get_config(True)

    version_file_path = os.path.join(utils.get_projects_dir(),
                                     config["versionInfo"]["project"],
                                     config["versionInfo"]["path"])
    if not os.path.exists(os.path.dirname(version_file_path)):
        os.makedirs(os.path.dirname(version_file_path))

    version_file = open(version_file_path, "w")
    version_file.write("""\"\"\"
Header comments and such.
\"\"\"

import os

__author__ = 'Alex Laird'
__copyright__ = 'Copyright 2017, Helium Edu'
__version__ = '{}'

# ############################
# Project configuration
# ############################
    
# Project information

PROJECT_NAME = os.environ.get('PROJECT_NAME')
MORE_SETTINGS = 'more_settings_after_this'
""".format(version))
    version_file.close()

    return version_file_path
Ejemplo n.º 4
0
def given_project_js_versioned_file_exists(project, filename="maths.js"):
    utils.get_config(True)

    versioned_file_path = os.path.join(utils.get_projects_dir(), project,
                                       filename)
    if not os.path.exists(os.path.dirname(versioned_file_path)):
        os.makedirs(os.path.dirname(versioned_file_path))

    versioned_file = open(versioned_file_path, "w")
    versioned_file.write("""/**
 * Copyright (c) 2017 Helium Edu.
 *
 * Some functions and stuff.
 *
 * @author Alex Laird
 * @version 1.2.2
 */
    
function sum(a, b) {
    return a + b
}
""")
    versioned_file.close()

    return versioned_file_path
Ejemplo n.º 5
0
    def test_set_build(self, mock_path_exists):
        # GIVEN
        utils._save_config(os.environ.get("HELIUMCLI_CONFIG_PATH"),
                           settings.get_default_settings())

        # WHEN
        main(["main.py", "--init", "set-build", "1.2.3"])

        # THEN
        self.mock_git_repo.return_value.git.checkout.assert_has_calls(
            [mock.call("1.2.3"), mock.call("1.2.3")])
        self.mock_subprocess_call.assert_any_call([
            "make", "install", "-C",
            os.path.join(utils.get_projects_dir(), "platform")
        ])
        self.mock_subprocess_call.assert_any_call([
            "make", "install", "-C",
            os.path.join(utils.get_projects_dir(), "frontend")
        ])
Ejemplo n.º 6
0
    def test_update_projects(self, mock_path_exists):
        # GIVEN
        utils._save_config(os.environ.get("HELIUMCLI_CONFIG_PATH"),
                           settings.get_default_settings())

        # WHEN
        main(["main.py", "--init", "update-projects"])

        # THEN
        self.assertEqual(self.mock_git_repo.return_value.git.pull.call_count,
                         3)
        self.mock_subprocess_call.assert_any_call([
            "make", "install", "-C",
            os.path.join(utils.get_projects_dir(), "platform")
        ])
        self.mock_subprocess_call.assert_any_call([
            "make", "install", "-C",
            os.path.join(utils.get_projects_dir(), "frontend")
        ])
Ejemplo n.º 7
0
    def test_start_servers(self):
        # GIVEN
        commonhelper.given_runserver_exists("platform")

        # WHEN
        main(["main.py", "--init", "start-servers"])

        # THEN
        self.mock_subprocess_popen.assert_called_once_with(
            os.path.join(utils.get_projects_dir(), "platform",
                         utils.get_config(True)["serverBinFilename"]))
Ejemplo n.º 8
0
def given_project_package_json_exists(project, version='1.2.2'):
    utils.get_config(True)

    versioned_file_path = os.path.join(utils.get_projects_dir(), project,
                                       'package.json')
    if not os.path.exists(os.path.dirname(versioned_file_path)):
        os.makedirs(os.path.dirname(versioned_file_path))

    versioned_file = open(versioned_file_path, "w")
    versioned_file.write("""{
  "name": "my-project",
  "version": \"""" + version + """\",
  "author": "Alex Laird",
  "dependencies": {
    "npm": "^1.2.3",
    "some-dep": "^4.5.6"
  }
}
""")
    versioned_file.close()

    return versioned_file_path
Ejemplo n.º 9
0
def given_project_python_versioned_file_exists(project, filename='maths.py'):
    utils.get_config(True)

    versioned_file_path = os.path.join(utils.get_projects_dir(), project,
                                       filename)
    if not os.path.exists(os.path.dirname(versioned_file_path)):
        os.makedirs(os.path.dirname(versioned_file_path))

    versioned_file = open(versioned_file_path, "w")
    versioned_file.write("""\"\"\"
Other header comments and such.
\"\"\"
    
__author__ = 'Alex Laird'
__copyright__ = 'Copyright 2017, Helium Edu'
__version__ = '1.2.2'
    
def sum(a, b):
    return a + b
""")
    versioned_file.close()

    return versioned_file_path