当前位置: 首页>>代码示例>>Python>>正文


Python TopLevelCommand.get_config_path方法代码示例

本文整理汇总了Python中fig.cli.main.TopLevelCommand.get_config_path方法的典型用法代码示例。如果您正苦于以下问题:Python TopLevelCommand.get_config_path方法的具体用法?Python TopLevelCommand.get_config_path怎么用?Python TopLevelCommand.get_config_path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在fig.cli.main.TopLevelCommand的用法示例。


在下文中一共展示了TopLevelCommand.get_config_path方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_get_project

# 需要导入模块: from fig.cli.main import TopLevelCommand [as 别名]
# 或者: from fig.cli.main.TopLevelCommand import get_config_path [as 别名]
 def test_get_project(self):
     command = TopLevelCommand()
     command.base_dir = 'tests/fixtures/longer-filename-figfile'
     project = command.get_project(command.get_config_path())
     self.assertEqual(project.name, 'longerfilenamefigfile')
     self.assertTrue(project.client)
     self.assertTrue(project.services)
开发者ID:OculusVR,项目名称:fig,代码行数:9,代码来源:cli_test.py

示例2: test_default_project_name

# 需要导入模块: from fig.cli.main import TopLevelCommand [as 别名]
# 或者: from fig.cli.main.TopLevelCommand import get_config_path [as 别名]
    def test_default_project_name(self):
        cwd = os.getcwd()

        try:
            os.chdir('tests/fixtures/simple-figfile')
            command = TopLevelCommand()
            project_name = command.get_project_name(command.get_config_path())
            self.assertEquals('simplefigfile', project_name)
        finally:
            os.chdir(cwd)
开发者ID:OculusVR,项目名称:fig,代码行数:12,代码来源:cli_test.py

示例3: CLITestCase

# 需要导入模块: from fig.cli.main import TopLevelCommand [as 别名]
# 或者: from fig.cli.main.TopLevelCommand import get_config_path [as 别名]
class CLITestCase(DockerClientTestCase):
    def setUp(self):
        super(CLITestCase, self).setUp()
        self.old_sys_exit = sys.exit
        sys.exit = lambda code=0: None
        self.command = TopLevelCommand()
        self.command.base_dir = 'tests/fixtures/simple-figfile'

    def tearDown(self):
        sys.exit = self.old_sys_exit
        self.project.kill()
        self.project.remove_stopped()

    @property
    def project(self):
        return self.command.get_project(self.command.get_config_path())

    @patch('sys.stdout', new_callable=StringIO)
    def test_ps(self, mock_stdout):
        self.project.get_service('simple').create_container()
        self.command.dispatch(['ps'], None)
        self.assertIn('simplefigfile_simple_1', mock_stdout.getvalue())

    @patch('sys.stdout', new_callable=StringIO)
    def test_ps_default_figfile(self, mock_stdout):
        self.command.base_dir = 'tests/fixtures/multiple-figfiles'
        self.command.dispatch(['up', '-d'], None)
        self.command.dispatch(['ps'], None)

        output = mock_stdout.getvalue()
        self.assertIn('multiplefigfiles_simple_1', output)
        self.assertIn('multiplefigfiles_another_1', output)
        self.assertNotIn('multiplefigfiles_yetanother_1', output)

    @patch('sys.stdout', new_callable=StringIO)
    def test_ps_alternate_figfile(self, mock_stdout):
        self.command.base_dir = 'tests/fixtures/multiple-figfiles'
        self.command.dispatch(['-f', 'fig2.yml', 'up', '-d'], None)
        self.command.dispatch(['-f', 'fig2.yml', 'ps'], None)

        output = mock_stdout.getvalue()
        self.assertNotIn('multiplefigfiles_simple_1', output)
        self.assertNotIn('multiplefigfiles_another_1', output)
        self.assertIn('multiplefigfiles_yetanother_1', output)

    @patch('fig.service.log')
    def test_pull(self, mock_logging):
        self.command.dispatch(['pull'], None)
        mock_logging.info.assert_any_call('Pulling simple (busybox:latest)...')
        mock_logging.info.assert_any_call('Pulling another (busybox:latest)...')

    @patch('sys.stdout', new_callable=StringIO)
    def test_build_no_cache(self, mock_stdout):
        self.command.base_dir = 'tests/fixtures/simple-dockerfile'
        self.command.dispatch(['build', 'simple'], None)

        mock_stdout.truncate(0)
        cache_indicator = 'Using cache'
        self.command.dispatch(['build', 'simple'], None)
        output = mock_stdout.getvalue()
        self.assertIn(cache_indicator, output)

        mock_stdout.truncate(0)
        self.command.dispatch(['build', '--no-cache', 'simple'], None)
        output = mock_stdout.getvalue()
        self.assertNotIn(cache_indicator, output)
    def test_up(self):
        self.command.dispatch(['up', '-d'], None)
        service = self.project.get_service('simple')
        another = self.project.get_service('another')
        self.assertEqual(len(service.containers()), 1)
        self.assertEqual(len(another.containers()), 1)

    def test_up_with_links(self):
        self.command.base_dir = 'tests/fixtures/links-figfile'
        self.command.dispatch(['up', '-d', 'web'], None)
        web = self.project.get_service('web')
        db = self.project.get_service('db')
        console = self.project.get_service('console')
        self.assertEqual(len(web.containers()), 1)
        self.assertEqual(len(db.containers()), 1)
        self.assertEqual(len(console.containers()), 0)

    def test_up_with_no_deps(self):
        self.command.base_dir = 'tests/fixtures/links-figfile'
        self.command.dispatch(['up', '-d', '--no-deps', 'web'], None)
        web = self.project.get_service('web')
        db = self.project.get_service('db')
        console = self.project.get_service('console')
        self.assertEqual(len(web.containers()), 1)
        self.assertEqual(len(db.containers()), 0)
        self.assertEqual(len(console.containers()), 0)

    def test_up_with_recreate(self):
        self.command.dispatch(['up', '-d'], None)
        service = self.project.get_service('simple')
        self.assertEqual(len(service.containers()), 1)

        old_ids = [c.id for c in service.containers()]

#.........这里部分代码省略.........
开发者ID:billsmith,项目名称:fig,代码行数:103,代码来源:cli_test.py

示例4: test_yaml_filename_check

# 需要导入模块: from fig.cli.main import TopLevelCommand [as 别名]
# 或者: from fig.cli.main.TopLevelCommand import get_config_path [as 别名]
 def test_yaml_filename_check(self):
     command = TopLevelCommand()
     command.base_dir = 'tests/fixtures/longer-filename-figfile'
     with mock.patch('fig.cli.command.log', autospec=True) as mock_log:
         self.assertTrue(command.get_config_path())
     self.assertEqual(mock_log.warning.call_count, 2)
开发者ID:OculusVR,项目名称:fig,代码行数:8,代码来源:cli_test.py

示例5: test_project_name_with_explicit_uppercase_base_dir

# 需要导入模块: from fig.cli.main import TopLevelCommand [as 别名]
# 或者: from fig.cli.main.TopLevelCommand import get_config_path [as 别名]
 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)
开发者ID:OculusVR,项目名称:fig,代码行数:7,代码来源:cli_test.py

示例6: CLITestCase

# 需要导入模块: from fig.cli.main import TopLevelCommand [as 别名]
# 或者: from fig.cli.main.TopLevelCommand import get_config_path [as 别名]
class CLITestCase(DockerClientTestCase):
    def setUp(self):
        super(CLITestCase, self).setUp()
        self.old_sys_exit = sys.exit
        sys.exit = lambda code=0: None
        self.command = TopLevelCommand()
        self.command.base_dir = 'tests/fixtures/simple-figfile'

    def tearDown(self):
        sys.exit = self.old_sys_exit
        self.project.kill()
        self.project.remove_stopped()

    @property
    def project(self):
        return self.command.get_project(self.command.get_config_path())

    def test_help(self):
        old_base_dir = self.command.base_dir
        self.command.base_dir = 'tests/fixtures/no-figfile'
        with self.assertRaises(SystemExit) as exc_context:
            self.command.dispatch(['help', 'up'], None)
            self.assertIn('Usage: up [options] [SERVICE...]', str(exc_context.exception))
        # self.project.kill() fails during teardown
        # unless there is a figfile.
        self.command.base_dir = old_base_dir

    @patch('sys.stdout', new_callable=StringIO)
    def test_ps(self, mock_stdout):
        self.project.get_service('simple').create_container()
        self.command.dispatch(['ps'], None)
        self.assertIn('simplefigfile_simple_1', mock_stdout.getvalue())

    @patch('sys.stdout', new_callable=StringIO)
    def test_ps_default_figfile(self, mock_stdout):
        self.command.base_dir = 'tests/fixtures/multiple-figfiles'
        self.command.dispatch(['up', '-d'], None)
        self.command.dispatch(['ps'], None)

        output = mock_stdout.getvalue()
        self.assertIn('multiplefigfiles_simple_1', output)
        self.assertIn('multiplefigfiles_another_1', output)
        self.assertNotIn('multiplefigfiles_yetanother_1', output)

    @patch('sys.stdout', new_callable=StringIO)
    def test_ps_alternate_figfile(self, mock_stdout):
        self.command.base_dir = 'tests/fixtures/multiple-figfiles'
        self.command.dispatch(['-f', 'fig2.yml', 'up', '-d'], None)
        self.command.dispatch(['-f', 'fig2.yml', 'ps'], None)

        output = mock_stdout.getvalue()
        self.assertNotIn('multiplefigfiles_simple_1', output)
        self.assertNotIn('multiplefigfiles_another_1', output)
        self.assertIn('multiplefigfiles_yetanother_1', output)

    @patch('fig.service.log')
    def test_pull(self, mock_logging):
        self.command.dispatch(['pull'], None)
        mock_logging.info.assert_any_call('Pulling simple (busybox:latest)...')
        mock_logging.info.assert_any_call('Pulling another (busybox:latest)...')

    @patch('sys.stdout', new_callable=StringIO)
    def test_build_no_cache(self, mock_stdout):
        self.command.base_dir = 'tests/fixtures/simple-dockerfile'
        self.command.dispatch(['build', 'simple'], None)

        mock_stdout.truncate(0)
        cache_indicator = 'Using cache'
        self.command.dispatch(['build', 'simple'], None)
        output = mock_stdout.getvalue()
        self.assertIn(cache_indicator, output)

        mock_stdout.truncate(0)
        self.command.dispatch(['build', '--no-cache', 'simple'], None)
        output = mock_stdout.getvalue()
        self.assertNotIn(cache_indicator, output)
    def test_up(self):
        self.command.dispatch(['up', '-d'], None)
        service = self.project.get_service('simple')
        another = self.project.get_service('another')
        self.assertEqual(len(service.containers()), 1)
        self.assertEqual(len(another.containers()), 1)

    def test_up_with_links(self):
        self.command.base_dir = 'tests/fixtures/links-figfile'
        self.command.dispatch(['up', '-d', 'web'], None)
        web = self.project.get_service('web')
        db = self.project.get_service('db')
        console = self.project.get_service('console')
        self.assertEqual(len(web.containers()), 1)
        self.assertEqual(len(db.containers()), 1)
        self.assertEqual(len(console.containers()), 0)

    def test_up_with_no_deps(self):
        self.command.base_dir = 'tests/fixtures/links-figfile'
        self.command.dispatch(['up', '-d', '--no-deps', 'web'], None)
        web = self.project.get_service('web')
        db = self.project.get_service('db')
        console = self.project.get_service('console')
        self.assertEqual(len(web.containers()), 1)
#.........这里部分代码省略.........
开发者ID:xiaohan2013,项目名称:fig,代码行数:103,代码来源:cli_test.py

示例7: CLITestCase

# 需要导入模块: from fig.cli.main import TopLevelCommand [as 别名]
# 或者: from fig.cli.main.TopLevelCommand import get_config_path [as 别名]
class CLITestCase(DockerClientTestCase):
    def setUp(self):
        super(CLITestCase, self).setUp()
        self.old_sys_exit = sys.exit
        sys.exit = lambda code=0: None
        self.command = TopLevelCommand()
        self.command.base_dir = "tests/fixtures/simple-figfile"

    def tearDown(self):
        sys.exit = self.old_sys_exit
        self.project.kill()
        self.project.remove_stopped()

    @property
    def project(self):
        return self.command.get_project(self.command.get_config_path())

    @patch("sys.stdout", new_callable=StringIO)
    def test_ps(self, mock_stdout):
        self.project.get_service("simple").create_container()
        self.command.dispatch(["ps"], None)
        self.assertIn("simplefigfile_simple_1", mock_stdout.getvalue())

    @patch("sys.stdout", new_callable=StringIO)
    def test_ps_default_figfile(self, mock_stdout):
        self.command.base_dir = "tests/fixtures/multiple-figfiles"
        self.command.dispatch(["up", "-d"], None)
        self.command.dispatch(["ps"], None)

        output = mock_stdout.getvalue()
        self.assertIn("multiplefigfiles_simple_1", output)
        self.assertIn("multiplefigfiles_another_1", output)
        self.assertNotIn("multiplefigfiles_yetanother_1", output)

    @patch("sys.stdout", new_callable=StringIO)
    def test_ps_alternate_figfile(self, mock_stdout):
        self.command.base_dir = "tests/fixtures/multiple-figfiles"
        self.command.dispatch(["-f", "fig2.yml", "up", "-d"], None)
        self.command.dispatch(["-f", "fig2.yml", "ps"], None)

        output = mock_stdout.getvalue()
        self.assertNotIn("multiplefigfiles_simple_1", output)
        self.assertNotIn("multiplefigfiles_another_1", output)
        self.assertIn("multiplefigfiles_yetanother_1", output)

    @patch("sys.stdout", new_callable=StringIO)
    def test_build_no_cache(self, mock_stdout):
        self.command.base_dir = "tests/fixtures/simple-dockerfile"
        self.command.dispatch(["build", "simple"], None)

        mock_stdout.truncate(0)
        cache_indicator = "Using cache"
        self.command.dispatch(["build", "simple"], None)
        output = mock_stdout.getvalue()
        self.assertIn(cache_indicator, output)

        mock_stdout.truncate(0)
        self.command.dispatch(["build", "--no-cache", "simple"], None)
        output = mock_stdout.getvalue()
        self.assertNotIn(cache_indicator, output)

    def test_up(self):
        self.command.dispatch(["up", "-d"], None)
        service = self.project.get_service("simple")
        another = self.project.get_service("another")
        self.assertEqual(len(service.containers()), 1)
        self.assertEqual(len(another.containers()), 1)

    def test_up_with_links(self):
        self.command.base_dir = "tests/fixtures/links-figfile"
        self.command.dispatch(["up", "-d", "web"], None)
        web = self.project.get_service("web")
        db = self.project.get_service("db")
        console = self.project.get_service("console")
        self.assertEqual(len(web.containers()), 1)
        self.assertEqual(len(db.containers()), 1)
        self.assertEqual(len(console.containers()), 0)

    def test_up_with_no_deps(self):
        self.command.base_dir = "tests/fixtures/links-figfile"
        self.command.dispatch(["up", "-d", "--no-deps", "web"], None)
        web = self.project.get_service("web")
        db = self.project.get_service("db")
        console = self.project.get_service("console")
        self.assertEqual(len(web.containers()), 1)
        self.assertEqual(len(db.containers()), 0)
        self.assertEqual(len(console.containers()), 0)

    def test_up_with_recreate(self):
        self.command.dispatch(["up", "-d"], None)
        service = self.project.get_service("simple")
        self.assertEqual(len(service.containers()), 1)

        old_ids = [c.id for c in service.containers()]

        self.command.dispatch(["up", "-d"], None)
        self.assertEqual(len(service.containers()), 1)

        new_ids = [c.id for c in service.containers()]

#.........这里部分代码省略.........
开发者ID:benlangfeld,项目名称:fig,代码行数:103,代码来源:cli_test.py


注:本文中的fig.cli.main.TopLevelCommand.get_config_path方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。