Esempio n. 1
0
def get_config_filename_for_files(filenames, subdir=None):
    project_dir = tempfile.mkdtemp()
    try:
        make_files(project_dir, filenames)
        command = TopLevelCommand()
        if subdir:
            command.base_dir = tempfile.mkdtemp(dir=project_dir)
        else:
            command.base_dir = project_dir
        return os.path.basename(command.get_config_path())
    finally:
        shutil.rmtree(project_dir)
Esempio n. 2
0
def get_config_filename_for_files(filenames, subdir=None):
    project_dir = tempfile.mkdtemp()
    try:
        make_files(project_dir, filenames)
        command = TopLevelCommand()
        if subdir:
            command.base_dir = tempfile.mkdtemp(dir=project_dir)
        else:
            command.base_dir = project_dir
        return os.path.basename(command.get_config_path())
    finally:
        shutil.rmtree(project_dir)
Esempio n. 3
0
 def test_get_project(self):
     command = TopLevelCommand()
     command.base_dir = 'tests/fixtures/longer-filename-composefile'
     project = command.get_project()
     self.assertEqual(project.name, 'longerfilenamecomposefile')
     self.assertTrue(project.client)
     self.assertTrue(project.services)
Esempio n. 4
0
 def test_get_project(self):
     command = TopLevelCommand()
     command.base_dir = 'tests/fixtures/longer-filename-composefile'
     project = command.get_project(command.get_config_path())
     self.assertEqual(project.name, 'longerfilenamecomposefile')
     self.assertTrue(project.client)
     self.assertTrue(project.services)
Esempio n. 5
0
def get_project(path):
    """
    get docker project given file path
    """
    logging.debug('get project ' + path)
    command = TopLevelCommand()
    command.base_dir = path
    project = command.get_project(command.get_config_path())
    return project
Esempio n. 6
0
def get_project(path):
    """
    get docker project given file path
    """
    logging.debug('get project ' + path)
    command = TopLevelCommand()
    command.base_dir = path
    project = command.get_project(command.get_config_path())
    return project
Esempio n. 7
0
 def test_project_name_with_explicit_uppercase_base_dir(self):
     command = TopLevelCommand()
     command.base_dir = 'tests/fixtures/UpperCaseDir'
     project_name = command.get_project_name(command.base_dir)
     self.assertEquals('uppercasedir', project_name)
Esempio n. 8
0
 def test_project_name_with_explicit_base_dir(self):
     command = TopLevelCommand()
     command.base_dir = 'tests/fixtures/simple-composefile'
     project_name = command.get_project_name(command.base_dir)
     self.assertEquals('simplecomposefile', project_name)
Esempio n. 9
0
 def test_project_name_with_explicit_uppercase_base_dir(self):
     command = TopLevelCommand()
     command.base_dir = 'tests/fixtures/UpperCaseDir'
     project_name = command.get_project_name(command.get_config_path())
     self.assertEquals('uppercasedir', project_name)
Esempio n. 10
0
 def test_project_name_with_explicit_base_dir(self):
     command = TopLevelCommand()
     command.base_dir = 'tests/fixtures/simple-composefile'
     project_name = command.get_project_name(command.get_config_path())
     self.assertEquals('simplecomposefile', project_name)
Esempio n. 11
0
 def test_yaml_filename_check(self):
     command = TopLevelCommand()
     command.base_dir = 'tests/fixtures/longer-filename-composefile'
     with mock.patch('compose.cli.command.log', autospec=True) as mock_log:
         self.assertTrue(command.get_config_path())
     self.assertEqual(mock_log.warning.call_count, 2)
Esempio n. 12
0
 def test_project_name_with_explicit_uppercase_base_dir(self):
     command = TopLevelCommand()
     command.base_dir = 'tests/fixtures/Simple-figfile'
     project_name = command.get_project_name(command.get_config_path())
     self.assertEquals('simplefigfile', project_name)