# Path: sc/cli.py
# @click.group()
# @click.version_option()
# @click.pass_context
# def cli(ctx):
#     """Smartcontainers for software and data preservation.
#     Smartcontainers provides a mechanism to add metadata to Docker
#     containers as a JSON-LD label. The metadata is contextualized using
#     W3C recommended PROV-O and ORCID IDs to capture provenance information.
#     The sc command wraps the docker commandline interface and passes any
#     docker command line parameters through to docker. Any command that changes
#     the state of the container is recorded in a prov graph and attached to the resultant
#     image.
#     """
# 
#     # Ignore config loading if we intend to create an orcid config
#     if ctx.args[0] == "config" and ctx.args[1] == "orcid":
#         return
# 
#     Success = False
#     while not Success:
#         result = config_file.read_config()
#         if 'Configuration does not exist.' in result:
#             print("User configuration needs to be initialized")
#             selected = None
#             while not selected:
#                 try:
#                     selected = click.prompt('Do you have an ORCID profile (Y/N)')
#                     if selected.lower() == 'y' or selected.lower() == 'yes':
#                         config_by_search()
#                         continue
# 
#                     if selected.lower() == 'n' or selected.lower() == 'no':
#                         print("Please provide some basic information:")
#                         query = {
#                             'first_name': click.prompt(
#                                 'Please enter a first name', default='',
#                                 show_default=False
#                             ),
#                             'last_name': click.prompt(
#                                 'Please enter a last name', default='',
#                                 show_default=False
#                             )
#                         }
#                         dockerUseruuid = str(uuid.uuid4())
#                         UUIDNS = Namespace("urn:uuid:")
#                         config_file.graph.bind("foaf", FOAF)
#                         config_file.graph.add( ( UUIDNS[dockerUseruuid], FOAF.givenName, Literal(query['first_name']) ) )
#                         config_file.graph.add( ( UUIDNS[dockerUseruuid], FOAF.familyName, Literal(query['last_name']) ) )
# 
#                         config_file.config_obj = config_file.graph.serialize(format='turtle')
#                         config_file.write_config()
#                 except KeyError:
#                     print('That is not a valid selection.  Please try again.\n')
#         else:
#             Success = True
#             graph = config_file.graph


import pytest
from click.testing import CliRunner
from sc import cli


@pytest.fixture
def runner():
    return CliRunner()


def test_cli(runner):
    result = runner.invoke(cli.cli)
    assert result.exit_code == 0
    assert not result.exception


def test_search(runner):
    # test option docker

# Path: sc/cli.py
# @click.group()
# @click.version_option()
# @click.pass_context
# def cli(ctx):
#     """Smartcontainers for software and data preservation.
#     Smartcontainers provides a mechanism to add metadata to Docker
#     containers as a JSON-LD label. The metadata is contextualized using
#     W3C recommended PROV-O and ORCID IDs to capture provenance information.
#     The sc command wraps the docker commandline interface and passes any
#     docker command line parameters through to docker. Any command that changes
#     the state of the container is recorded in a prov graph and attached to the resultant
#     image.
#     """
# 
#     # Ignore config loading if we intend to create an orcid config
#     if ctx.args[0] == "config" and ctx.args[1] == "orcid":
#         return
# 
#     Success = False
#     while not Success:
#         result = config_file.read_config()
#         if 'Configuration does not exist.' in result:
#             print("User configuration needs to be initialized")
#             selected = None
#             while not selected:
#                 try:
#                     selected = click.prompt('Do you have an ORCID profile (Y/N)')
#                     if selected.lower() == 'y' or selected.lower() == 'yes':
#                         config_by_search()
#                         continue
# 
#                     if selected.lower() == 'n' or selected.lower() == 'no':
#                         print("Please provide some basic information:")
#                         query = {
#                             'first_name': click.prompt(
#                                 'Please enter a first name', default='',
#                                 show_default=False
#                             ),
#                             'last_name': click.prompt(
#                                 'Please enter a last name', default='',
#                                 show_default=False
#                             )
#                         }
#                         dockerUseruuid = str(uuid.uuid4())
#                         UUIDNS = Namespace("urn:uuid:")
#                         config_file.graph.bind("foaf", FOAF)
#                         config_file.graph.add( ( UUIDNS[dockerUseruuid], FOAF.givenName, Literal(query['first_name']) ) )
#                         config_file.graph.add( ( UUIDNS[dockerUseruuid], FOAF.familyName, Literal(query['last_name']) ) )
# 
#                         config_file.config_obj = config_file.graph.serialize(format='turtle')
#                         config_file.write_config()
#                 except KeyError:
#                     print('That is not a valid selection.  Please try again.\n')
#         else:
#             Success = True
#             graph = config_file.graph


# Path: tests/unit/test_cli.py
import pytest
from click.testing import CliRunner
from sc import cli



@pytest.fixture
def runner():
    return CliRunner()


def test_cli(runner):
    result = runner.invoke(cli.cli)
    assert result.exit_code == 0
    assert not result.exception


def test_search(runner):
    # test option docker

    result = runner.invoke(cli.cli, input='search')