# 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
    except Exception as err:
        raise AssertionError('could not create the docker client ' + str(err))

    try:
        docker_client.images.get(img_name)
        raise AssertionError('If the image was deleted then an attempt to get it '
                             'should raise a docker exception')
    except Exception:
        pass

    images.imageIsLoaded(img_name, exists=False)
    images.assertNoImages()


@pytest.mark.plugin('slicer_cli_web')
def testBadImageDelete(images):
    # attempt to delete a non existent image
    img_name = 'null/null:null'
    images.assertNoImages()
    images.deleteImage(img_name, False, )


@pytest.mark.plugin('slicer_cli_web')
def testXmlEndpoint(images, server, admin):
    # loads an image and attempts to run an arbitrary xml endpoint

    img_name = 'girder/slicer_cli_web:small'
    images.addImage(img_name, JobStatus.SUCCESS)
    images.imageIsLoaded(img_name, True)


# 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

    except Exception as err:
        raise AssertionError('could not create the docker client ' + str(err))

    try:
        docker_client.images.get(img_name)
        raise AssertionError('If the image was deleted then an attempt to get it '
                             'should raise a docker exception')
    except Exception:
        pass

    images.imageIsLoaded(img_name, exists=False)
    images.assertNoImages()


@pytest.mark.plugin('slicer_cli_web')
def testBadImageDelete(images):
    # attempt to delete a non existent image
    img_name = 'null/null:null'
    images.assertNoImages()
    images.deleteImage(img_name, False, )


@pytest.mark.plugin('slicer_cli_web')
def testXmlEndpoint(images, server, admin):
    # loads an image and attempts to run an arbitrary xml endpoint

    img_name = 'girder/slicer_cli_web:small'
    images.addImage(img_name, JobStatus.SUCCESS)
    images.imageIsLoaded(img_name, True)


    name, tag = splitName(img_name)