Esempio n. 1
0
def read_config():
    """Read from rotest.yml config elrados segment."""
    config_path = search_config_file()
    if config_path is not None:
        with open(config_path, "r") as config_file:
            configuration_content = config_file.read()

        yaml_configuration = yaml.load(configuration_content)

    else:
        yaml_configuration = {}

    return AttrDict(yaml_configuration.get("elrados", {}))
Esempio n. 2
0
def start_server():
    """Start Django server with the port from the config file.

    Attempt to use the project's manage.py file if exists, otherwise use
    the general 'django-admin' command.
    """
    app_directory = os.path.dirname(search_config_file())
    manage_py_location = os.path.join(app_directory, "manage.py")
    if os.path.exists(manage_py_location):
        command = "python " + manage_py_location

    else:
        command = "django-admin"

    command += " runserver 0.0.0.0:{}".format(DJANGO_MANAGER_PORT)

    os.system(command)
Esempio n. 3
0
def get_configuration():
    """Get configuration for accessing Report Portal system."""
    config_file = search_config_file()
    with open(config_file, "r") as rotest_configuration:
        content = yaml.load(rotest_configuration.read())

    if "reportportal" not in content:
        raise ValueError("No 'reportportal' key is defined in {}. "
                         "Instead, found the following content:\n{}".format(
                             config_file, content))

    configuration = AttrDict(content["reportportal"])

    if REPORTPORTAL_TOKEN not in os.environ:
        raise ValueError(
            "You need to define the environment variable {} in "
            "order to access Report Portal".format(REPORTPORTAL_TOKEN))

    configuration.token = os.environ[REPORTPORTAL_TOKEN]
    return configuration
Esempio n. 4
0
 def test_finding_configuration_file_on_ancestor_directories(self, *_args):
     """Test finding the config file in the non-direct ancestor."""
     self.assertEqual(search_config_file(),
                      str(pathlib2.Path("/home/user/project/.rotest.yml")))
Esempio n. 5
0
 def test_config_file_cannot_be_found(self, *_args):
     """Test non-existing config file scenario."""
     self.assertEqual(search_config_file(), None)