Ejemplo n.º 1
0
    def test_create_zip(self):
        workspace = Workspace(None, MockExecutive(should_log=True))

        class MockZipFile(object):
            def __init__(self, path):
                self.filename = path

        with OutputCapture(level=logging.INFO) as captured:
            archive = workspace.create_zip('/zip/path', '/source/path',
                                           MockZipFile)
        self.assertEqual(
            captured.root.log.getvalue(),
            "MOCK run_command: ['zip', '-9', '-r', '/zip/path', '.'], cwd=/source/path\n"
        )
        self.assertEqual(archive.filename, "/zip/path")
Ejemplo n.º 2
0
    def test_create_zip_exception(self):
        workspace = Workspace(
            None, MockExecutive(should_log=True, should_throw=True))

        class MockZipFile(object):
            def __init__(self, path):
                self.filename = path

        with OutputCapture(level=logging.INFO) as captured:
            archive = workspace.create_zip('/zip/path', '/source/path',
                                           MockZipFile)
        self.assertEqual(
            captured.root.log.getvalue(),
            '''MOCK run_command: ['zip', '-9', '-r', '/zip/path', '.'], cwd=/source/path
Workspace.create_zip failed in /source/path:
MOCK ScriptError

MOCK output of child process
''',
        )

        self.assertIsNone(archive)