示例#1
0
 def test_rebuild_image_once(self):
     r = Runner(self.docker, "test_proj")
     image_name = "django_parallel_tests/test_proj"
     self.assertFalse(self.docker.images(name=image_name))
     r.launch_parallel_tests()
     self.assertTrue(self.docker.images(name=image_name))
     
     with patch.object(Runner, 'build_image') as mock:
         r.launch_parallel_tests()
         self.assertFalse(mock.called)
         self.assertTrue(self.docker.images(name=image_name))
示例#2
0
 def test_rebuild_image_when_no_image(self):
     r = Runner(self.docker, "test_proj", requirements=set())
     image_name = "django_parallel_tests/test_proj"
     self.assertFalse(self.docker.images(name=image_name))
     r.launch_parallel_tests()
     self.assertTrue(self.docker.images(name=image_name))
     
     r = Runner(self.docker, "test_proj", requirements=REQ)
     with patch.object(Runner, 'build_image') as mock:
         r.launch_parallel_tests()
         self.assertTrue(mock.called)
    def handle(self, *args, **options):
        required_settings = ["TEST_APPS", "PROJECT_NAME", "REQUIREMENTS"]
        for required_setting in required_settings:
            if not hasattr(settings, required_setting):
                print "Please set the %s settings" % required_setting
                return

        docker_conn = docker.Client(
            base_url='unix://var/run/docker.sock',
            version='1.12',
            timeout=10
        )

        runner = Runner(
            docker_conn,
            settings.PROJECT_NAME,
            requirements=get_requirements(settings.REQUIREMENTS),
            tests=settings.TEST_APPS,
            verbose=False
        )
        return runner.launch_parallel_tests()