# Path: shipwright/_lib/cli.py
# def argparser():
#     def a_arg(parser, *args, **kwargs):
# def parse_registry_logins(registry_logins):
# def _flatten(items):
# def old_style_arg_dict(namespace):
# def main():
# def process_arguments(path, arguments, client_cfg, environ):
#     def default(self, obj):
# def run(path, arguments, client_cfg, environ, new_style_args=None):
# def exit(msg):
# def memo(f, arg, memos={}):
# def pretty_event(evt, show_progress):
# def highlight(name):
#     def highlight_(msg):
# def switch(rec, show_progress):
# class SetJSONEncoder(json.JSONEncoder):


from shipwright._lib import cli
def test_aux_record():
    assert switch(aux) is None


def test_unhandled_record():
    assert switch(unhandled) == '{"event": "unhandled"}'


def test_status():
    assert switch({
        'status': 'Not Downloading xyz',
        'id': 'eg',
    }) == '[STATUS] eg: Not Downloading xyz'


def test_progress():
    evt = {
        'status': 'Downloading xyz',
        'id': 'eg',
        'progressDetail': {'current': 10, 'total': 100},
    }
    assert cli.switch(evt, True) == '[STATUS] eg: Downloading xyz 10/100\r'


def test_hide_progress():
    evt = {
        'status': 'Downloading xyz',
        'id': 'eg',
        'progressDetail': {'current': 10, 'total': 100},
    }

# Path: shipwright/_lib/cli.py
# def argparser():
#     def a_arg(parser, *args, **kwargs):
# def parse_registry_logins(registry_logins):
# def _flatten(items):
# def old_style_arg_dict(namespace):
# def main():
# def process_arguments(path, arguments, client_cfg, environ):
#     def default(self, obj):
# def run(path, arguments, client_cfg, environ, new_style_args=None):
# def exit(msg):
# def memo(f, arg, memos={}):
# def pretty_event(evt, show_progress):
# def highlight(name):
#     def highlight_(msg):
# def switch(rec, show_progress):
# class SetJSONEncoder(json.JSONEncoder):


# Path: tests/test_switch.py
from shipwright._lib import cli

def test_aux_record():
    assert switch(aux) is None


def test_unhandled_record():
    assert switch(unhandled) == '{"event": "unhandled"}'


def test_status():
    assert switch({
        'status': 'Not Downloading xyz',
        'id': 'eg',
    }) == '[STATUS] eg: Not Downloading xyz'


def test_progress():
    evt = {
        'status': 'Downloading xyz',
        'id': 'eg',
        'progressDetail': {'current': 10, 'total': 100},
    }
    assert cli.switch(evt, True) == '[STATUS] eg: Downloading xyz 10/100\r'


def test_hide_progress():
    evt = {
        'status': 'Downloading xyz',
        'id': 'eg',
        'progressDetail': {'current': 10, 'total': 100},
    }

    assert cli.switch(evt, False) is None