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)
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)
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)
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
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)
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)
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)
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)
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)
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)