示例#1
0
    def test_primary_container_created_with_rm(self, mock_container):
        data = yaml.load('''
        test-task:
            type: task
            primary: test-instance
        ''')

        containers = {}
        task = Task('test-task', data['test-task'])
        task._container_data = containers
        task.primary

        args, kwargs = mock_container.call_args

        self.assertTrue(kwargs['remove'])
示例#2
0
    def test_other_container_created_without_rm(self, mock_container):
        data = yaml.load('''
        test-task:
            type: task
            images:
              - test-instance
        ''')

        containers = {}
        task = Task('test-task', data['test-task'])
        task._container_data = containers
        task.containers

        args, kwargs = mock_container.call_args

        self.assertFalse(kwargs.get('remove'))
示例#3
0
    def test_multiple_instance_task(self, mock_container):
        data = yaml.load('''
        test-task:
            type: task
            primary: test-instance
            images:
                - test-instance2
        ''')
        fake = MagicMock()
        fake.get_run_command.return_value = 'working'
        fake.get_cleanup_command.return_value = 'cleaning'
        mock_container.return_value = fake

        task = Task('test-task', data['test-task'])
        fake.task = task
        commands = task.run()
        expected = ['working', 'working', 'cleaning']
        self.assertEqual(expected, commands[-3:])
示例#4
0
    def test_build_container_uses_setup_commands(self, mock_container):
        data = yaml.load('''
        test-task:
            type: task
            images:
              - test-instance
        ''')

        fake = MagicMock()
        fake.build = "/root"
        fake.get_setup_command.return_value = "setup"
        fake.get_run_command.return_value = "run"
        fake.get_cleanup_command.return_value = "cleanup"
        mock_container.return_value = fake
        containers = yaml.load('''
        test-instance:
            build: /root
        ''')
        task = Task('test-task', data['test-task'])
        commands = task.run()
        self.assertIn('setup', commands)