Exemplo n.º 1
0
def test_method_validation_not_a_docker_tar(submission_file):
    """ Upload something that isnt a docker file should be invalid """
    method = MethodFactory(image__from_path=submission_file)
    assert method.ready == False

    with pytest.raises(ValidationError):
        validate_docker_image_async(pk=method.pk,
                                    app_label=method._meta.app_label,
                                    model_name=method._meta.model_name)

    method = Method.objects.get(pk=method.pk)
    assert method.ready == False
    assert 'manifest.json not found' in method.status
Exemplo n.º 2
0
def test_method_validation_invalid_dockefile(alpine_images):
    """ Uploading two images in a tar archive should fail """
    method = MethodFactory(image__from_path=alpine_images)
    assert method.ready == False

    with pytest.raises(ValidationError):
        validate_docker_image_async(pk=method.pk,
                                    app_label=method._meta.app_label,
                                    model_name=method._meta.model_name)

    method = Method.objects.get(pk=method.pk)
    assert method.ready == False
    assert 'should only have 1 image' in method.status
Exemplo n.º 3
0
def test_method_validation_invalid_dockerfile(alpine_images):
    """ Uploading two images in a tar archive should fail """
    method = MethodFactory(image__from_path=alpine_images)
    assert method.ready == False

    with pytest.raises(ValidationError):
        validate_docker_image_async(
            pk=method.pk,
            app_label=method._meta.app_label,
            model_name=method._meta.model_name,
        )

    method = Method.objects.get(pk=method.pk)
    assert method.ready == False
    assert "should only have 1 image" in method.status
Exemplo n.º 4
0
def test_method_validation_not_a_docker_tar(submission_file):
    """ Upload something that isnt a docker file should be invalid """
    method = MethodFactory(image__from_path=submission_file)
    assert method.ready == False

    with pytest.raises(ValidationError):
        validate_docker_image_async(
            pk=method.pk,
            app_label=method._meta.app_label,
            model_name=method._meta.model_name,
        )

    method = Method.objects.get(pk=method.pk)
    assert method.ready == False
    assert "manifest.json not found" in method.status
Exemplo n.º 5
0
def test_method_validation_root_dockerfile(root_image):
    """ Uploading two images in a tar archive should fail """
    method = MethodFactory(image__from_path=root_image)
    assert method.ready == False

    with pytest.raises(ValidationError):
        validate_docker_image_async(
            pk=method.pk,
            app_label=method._meta.app_label,
            model_name=method._meta.model_name,
        )

    method = Method.objects.get(pk=method.pk)
    assert method.ready == False
    assert "runs as root" in method.status
Exemplo n.º 6
0
def test_method_validation(evaluation_image):
    """ The validator should set the correct sha256 and set the ready bit """
    container, sha256 = evaluation_image
    method = MethodFactory(image__from_path=container)

    # The method factory fakes the sha256 on creation
    assert method.image_sha256 != sha256
    assert method.ready == False

    validate_docker_image_async(pk=method.pk,
                                app_label=method._meta.app_label,
                                model_name=method._meta.model_name)

    method = Method.objects.get(pk=method.pk)
    assert method.image_sha256 == sha256
    assert method.ready == True
Exemplo n.º 7
0
def test_method_validation(evaluation_image):
    """ The validator should set the correct sha256 and set the ready bit """
    container, sha256 = evaluation_image
    method = MethodFactory(image__from_path=container)

    # The method factory fakes the sha256 on creation
    assert method.image_sha256 != sha256
    assert method.ready == False

    validate_docker_image_async(
        pk=method.pk,
        app_label=method._meta.app_label,
        model_name=method._meta.model_name,
    )

    method = Method.objects.get(pk=method.pk)
    assert method.image_sha256 == sha256
    assert method.ready == True