# Path: tests/conftest.py
# def splitName(name):
#     if ':' in name:
#         imageAndTag = name.split(':')
#     else:
#         imageAndTag = name.split('@')
#     return imageAndTag[0], imageAndTag[1]


import pytest
import docker
import json
from girder_jobs.constants import JobStatus
from pytest_girder.assertions import assertStatus
from pytest_girder.utils import getResponseBody
from .conftest import splitName
    images.addImage(img_name, None, 400)
    images.assertNoImages()


@pytest.mark.plugin('slicer_cli_web')
def testDockerDelete(images):
    # just delete the metadata in the mongo database
    # don't delete the docker image
    img_name = 'girder/slicer_cli_web:small'
    images.assertNoImages()
    images.addImage(img_name, JobStatus.SUCCESS)
    images.imageIsLoaded(img_name, True)
    images.deleteImage(img_name, True, False)
    images.imageIsLoaded(img_name, exists=False)
    images.assertNoImages()


@pytest.mark.plugin('slicer_cli_web')
def testDockerDeleteFull(images):
    # attempt to delete docker image metadata and the image off the local
    # machine
    img_name = 'girder/slicer_cli_web:small'
    images.assertNoImages()
    images.addImage(img_name, JobStatus.SUCCESS)
    images.imageIsLoaded(img_name, True)
    images.deleteImage(img_name, True, True, JobStatus.SUCCESS)

    try:
        docker_client = docker.from_env(version='auto')
    except Exception as err:

# Path: tests/conftest.py
# def splitName(name):
#     if ':' in name:
#         imageAndTag = name.split(':')
#     else:
#         imageAndTag = name.split('@')
#     return imageAndTag[0], imageAndTag[1]


# Path: tests/test_docker.py
import pytest
import docker
import json
from girder_jobs.constants import JobStatus
from pytest_girder.assertions import assertStatus
from pytest_girder.utils import getResponseBody
from .conftest import splitName

    images.addImage(img_name, None, 400)
    images.assertNoImages()


@pytest.mark.plugin('slicer_cli_web')
def testDockerDelete(images):
    # just delete the metadata in the mongo database
    # don't delete the docker image
    img_name = 'girder/slicer_cli_web:small'
    images.assertNoImages()
    images.addImage(img_name, JobStatus.SUCCESS)
    images.imageIsLoaded(img_name, True)
    images.deleteImage(img_name, True, False)
    images.imageIsLoaded(img_name, exists=False)
    images.assertNoImages()


@pytest.mark.plugin('slicer_cli_web')
def testDockerDeleteFull(images):
    # attempt to delete docker image metadata and the image off the local
    # machine
    img_name = 'girder/slicer_cli_web:small'
    images.assertNoImages()
    images.addImage(img_name, JobStatus.SUCCESS)
    images.imageIsLoaded(img_name, True)
    images.deleteImage(img_name, True, True, JobStatus.SUCCESS)

    try:
        docker_client = docker.from_env(version='auto')
    except Exception as err:

        raise AssertionError('could not create the docker client ' + str(err))