예제 #1
0
    def test_attach_to_logs(self):
        project = mock.create_autospec(Project)
        log_printer = mock.create_autospec(LogPrinter, containers=[])
        service_names = ["web", "db"]
        timeout = 12

        with mock.patch("compose.cli.main.signal", autospec=True) as mock_signal:
            attach_to_logs(project, log_printer, service_names, timeout)

        mock_signal.signal.assert_called_once_with(mock_signal.SIGINT, mock.ANY)
        log_printer.run.assert_called_once_with()
        project.stop.assert_called_once_with(service_names=service_names, timeout=timeout)
예제 #2
0
    def test_attach_to_logs(self):
        project = mock.create_autospec(Project)
        log_printer = mock.create_autospec(LogPrinter, containers=[])
        service_names = ['web', 'db']
        timeout = 12

        with mock.patch('compose.cli.main.signal', autospec=True) as mock_signal:
            attach_to_logs(project, log_printer, service_names, timeout)

        mock_signal.signal.assert_called_once_with(mock_signal.SIGINT, mock.ANY)
        log_printer.run.assert_called_once_with()
        project.stop.assert_called_once_with(
            service_names=service_names,
            timeout=timeout)
예제 #3
0
    def test_attach_to_logs(self):
        project = mock.create_autospec(Project)
        log_printer = mock.create_autospec(LogPrinter, containers=[])
        service_names = ['web', 'db']
        timeout = 12

        with mock.patch('compose.cli.main.signal', autospec=True) as mock_signal:
            attach_to_logs(project, log_printer, service_names, timeout)

        assert mock_signal.signal.mock_calls == [
            mock.call(mock_signal.SIGINT, mock.ANY),
            mock.call(mock_signal.SIGTERM, mock.ANY),
        ]
        log_printer.run.assert_called_once_with()
예제 #4
0
    def test_warning_in_swarm_mode(self):
        mock_client = mock.create_autospec(docker.APIClient)
        mock_client.info.return_value = {'Swarm': {'LocalNodeState': 'active'}}

        with mock.patch('compose.cli.main.log') as fake_log:
            warn_for_swarm_mode(mock_client)
            assert fake_log.warn.call_count == 1
예제 #5
0
파일: main_test.py 프로젝트: docker/compose
    def test_warning_in_swarm_mode(self):
        mock_client = mock.create_autospec(docker.APIClient)
        mock_client.info.return_value = {'Swarm': {'LocalNodeState': 'active'}}

        with mock.patch('compose.cli.main.log') as fake_log:
            warn_for_swarm_mode(mock_client)
            assert fake_log.warning.call_count == 1
예제 #6
0
파일: test_update.py 프로젝트: lmacken/dnf
    def test_update_not_found(self):
        base = dnf.Base()
        base._sack = support.mock_sack('updates')
        base._goal = goal = mock.create_autospec(hawkey.Goal)

        self.assertRaises(dnf.exceptions.PackageNotFoundError,
                          base.update, 'non-existent')
        self.assertEqual(goal.mock_calls, [])
예제 #7
0
파일: test_update.py 프로젝트: zde/dnf
    def test_update_not_found(self):
        base = dnf.Base()
        base._sack = support.mock_sack('updates')
        base._goal = goal = mock.create_autospec(hawkey.Goal)

        with self.assertRaises(dnf.exceptions.MarkingError) as context:
            base.upgrade('non-existent')
        self.assertEqual(context.exception.pkg_spec, 'non-existent')
        self.assertEqual(goal.mock_calls, [])
예제 #8
0
 def setUp(self, mock_registry_class):
     self.mock_registry = mock_registry_class
     self.mock_registry_type = mock.create_autospec(spec=V1(address="https://v1.com"), spec_set=True)
     self.mock_registry.return_value = self.mock_registry_type
     self.api = ServiceFactory(name='api')
     self.build = ServiceFactory(name='build')
     self.database = ServiceFactory(name='database')
     self.cache = ServiceFactory(name='cache')
     self.nginx = ServiceFactory(name='nginx')
예제 #9
0
 def setUp(self, mock_registry_class):
     self.mock_registry = mock_registry_class
     self.mock_registry_type = mock.create_autospec(
         spec=V1(address="https://v1.com"), spec_set=True)
     self.mock_registry.return_value = self.mock_registry_type
     self.api = ServiceFactory(name='api')
     self.build = ServiceFactory(name='build')
     self.database = ServiceFactory(name='database')
     self.cache = ServiceFactory(name='cache')
     self.nginx = ServiceFactory(name='nginx')
예제 #10
0
def mock_client():
    return mock.create_autospec(docker.APIClient)
예제 #11
0
def mock_container(service, number):
    return mock.create_autospec(
        container.Container, service=service, number=number, name_without_project="{0}_{1}".format(service, number)
    )
예제 #12
0
def mock_container(service, number):
    return mock.create_autospec(container.Container,
                                service=service,
                                number=number,
                                name_without_project='{0}_{1}'.format(
                                    service, number))
예제 #13
0
파일: test_downgrade.py 프로젝트: zde/dnf
 def setUp(self):
     self._base = dnf.Base()
     self._base._sack = support.mock_sack("main")
     self._base._goal = self._goal = mock.create_autospec(hawkey.Goal)
예제 #14
0
def mock_client():
    return mock.create_autospec(docker.Client)