def test_additional_bindings(self): # Some additional stuff to bind into docker tempDir = tempfile.mkdtemp() tempFile = tempfile.mktemp() with open(tempFile, 'w') as f: f.write('data') # One binding specifies the target path in the container, the other doesn't # so it defaults to the same path a = DockerApp( 'a', 'a', image='ubuntu:14.04', command="cp /opt/file %s" % (tempDir,), additionalBindings=[tempDir, "%s:/opt/file" % (tempFile,)] ) a.execute() # We copied the file into the directory, but since in the container the # file was called "file" we'll see it with that name in tempDir self.assertEquals(1, len(os.listdir(tempDir))) with open(os.path.join(tempDir, 'file')) as f: data = f.read() self.assertEquals('data', data) # Cleanup os.unlink(tempFile) shutil.rmtree(tempDir)
def test_additional_bindings(self): # Some additional stuff to bind into docker tempDir = tempfile.mkdtemp() tempFile = tempfile.mktemp() with open(tempFile, 'w') as f: f.write('data') # One binding specifies the target path in the container, the other doesn't # so it defaults to the same path a = DockerApp( 'a', 'a', image='ubuntu:14.04', command="cp /opt/file %s" % (tempDir, ), additionalBindings=[tempDir, "%s:/opt/file" % (tempFile, )]) a.execute() # We copied the file into the directory, but since in the container the # file was called "file" we'll see it with that name in tempDir self.assertEqual(1, len(os.listdir(tempDir))) with open(os.path.join(tempDir, 'file')) as f: data = f.read() self.assertEqual('data', data) # Cleanup os.unlink(tempFile) shutil.rmtree(tempDir)
def assertMsgIsCorrect(msg, command): a = DockerApp('a', 'a', image='ubuntu:14.04', command=command) b = FileDROP('b','b') a.addOutput(b) with DROPWaiterCtx(self, b, 100): a.execute() self.assertEquals(msg, droputils.allDropContents(b))
def assertMsgIsCorrect(msg, command): a = DockerApp('a', 'a', image='ubuntu:14.04', command=command) b = FileDROP('b', 'b') a.addOutput(b) with DROPWaiterCtx(self, b, 100): a.execute() self.assertEqual(six.b(msg), droputils.allDropContents(b))