Beispiel #1
0
 def test_create_context(self):
     s = StringIO()
     create_context(["Django"], s)
     s.seek(0)
     context = tarfile.TarFile(fileobj=s)
     names = context.getnames()
     self.assertEqual(len(names), 2)
     self.assertIn("Dockerfile", names)
     self.assertIn("requirements.txt", names)
    def build_image(self):
        if len(self.project_name) < 3:
            return False

        tar_fileobj = StringIO()
        create_context(self.requirements, tar_fileobj)
        tar_fileobj.seek(0)

        success = False
        for chunk in self.docker.build(
            tag="django_parallel_tests/%s" % self.project_name, quiet=False, fileobj=tar_fileobj, custom_context=True
        ):
            if "Successfully built" in chunk:
                success = True
            if self.verbose:
                print json.loads(chunk)["stream"],
        tar_fileobj.close()

        return success