Ejemplo n.º 1
0
 def __init__(self):
     cli_args = Command()
     ep = dict()
     if cli_args.contains_switches("p"):
         ep["domain"], ep["port"] = cli_args.get_definition("p").rsplit(
             ":", 1)
     else:
         ep["domain"], ep["port"] = (G1_TEST_DEFAULT_ENDPOINT
                                     if cli_args.contains_switches("gtest")
                                     else G1_DEFAULT_ENDPOINT)
     if ep["domain"].startswith("[") and ep["domain"].endswith("]"):
         ep["domain"] = ep["domain"][1:-1]
     self.ep = ep
Ejemplo n.º 2
0
def test_command_get_alternate_short_def_syntax():
    set_sysargv(test_command_8)
    c = Command()
    assert c.get_definition('name') == "tests/aaa.txt"
Ejemplo n.º 3
0
def test_command_get_long_def_multioption_command():
    set_sysargv(test_command_1)
    c = Command()
    assert c.get_definition('name') == "longdef"
Ejemplo n.º 4
0
def test_command_get_short_def_multioption_command():
    set_sysargv(test_command_1)
    c = Command()
    assert c.get_definition('n') == "shortdef"
Ejemplo n.º 5
0
def test_command_get_alternate_long_def():
    set_sysargv(test_command_1)
    c = Command()
    assert c.get_definition('nameeq') == "longdefeq"
Ejemplo n.º 6
0
def test_command_get_long_def():
    set_sysargv(test_command_3)
    c = Command()
    assert c.get_definition('long') == "lastpos"
Ejemplo n.º 7
0
def test_command_get_short_def():
    set_sysargv(test_command_2)
    c = Command()
    assert c.get_definition('s') == "lastpos"
Ejemplo n.º 8
0
def manage_cmd():
    cli_args = Command()
    if cli_args.is_version_request():
        message_exit(SILKAJ_VERSION)

    subcmd = [
        "license",
        "about",
        "info",
        "diffi",
        "net",
        "network",
        "issuers",
        "argos",
        "amount",
        "tx",
        "transaction",
        "cert",
        "generate_auth_file",
        "id",
        "identities",
        "wot",
    ]
    if (
        cli_args.is_help_request()
        or cli_args.is_usage_request()
        or cli_args.subcmd not in subcmd
    ):
        usage()

    if cli_args.subcmd == "about":
        about()
    elif cli_args.subcmd == "info":
        currency_info()

    elif cli_args.subcmd == "diffi":
        difficulties()

    elif cli_args.subcmd == "net" or cli_args.subcmd == "network":
        if cli_args.contains_switches("sort"):
            set_network_sort_keys(cli_args.get_definition("sort"))
        if cli_args.contains_switches("s"):
            set_network_sort_keys(cli_args.get_definition("s"))
        network_info(cli_args.contains_switches("discover"))

    elif (
        cli_args.subcmd == "issuers"
        and cli_args.subsubcmd
        and int(cli_args.subsubcmd) >= 0
    ):
        list_issuers(int(cli_args.subsubcmd), cli_args.contains_switches("last"))

    elif cli_args.subcmd == "argos":
        argos_info()

    elif cli_args.subcmd == "amount":
        cmd_amount(cli_args)

    elif cli_args.subcmd == "tx" or cli_args.subcmd == "transaction":
        send_transaction(cli_args)

    elif cli_args.subcmd == "cert":
        send_certification(cli_args)

    elif cli_args.subcmd == "generate_auth_file":
        generate_auth_file(cli_args)

    elif cli_args.subcmd == "id" or cli_args.subcmd == "identities":
        id_pubkey_correspondence(cli_args.subsubcmd)

    elif cli_args.subcmd == "wot":
        received_sent_certifications(cli_args.subsubcmd)

    elif cli_args.subcmd == "license":
        display_license()
def test_command_get_def_when_no_defs():
    set_sysargv(test_command_6)
    c = Command()
    with pytest.raises(MissingDictionaryKeyError):
        c.get_definition('bogus')
def test_command_get_alternate_short_def_syntax():
    set_sysargv(test_command_8)
    c = Command()
    assert c.get_definition('name') == "tests/aaa.txt"
def test_command_get_long_def_multioption_command():
    set_sysargv(test_command_1)
    c = Command()
    assert c.get_definition('name') == "longdef"
def test_command_get_short_def_multioption_command():
    set_sysargv(test_command_1)
    c = Command()
    assert c.get_definition('n') == "shortdef"
def test_command_get_alternate_long_def():
    set_sysargv(test_command_1)
    c = Command()
    assert c.get_definition('nameeq') == "longdefeq"
def test_command_get_long_def():
    set_sysargv(test_command_3)
    c = Command()
    assert c.get_definition('long') == "lastpos"
def test_command_get_short_def():
    set_sysargv(test_command_2)
    c = Command()
    assert c.get_definition('s') == "lastpos"
Ejemplo n.º 16
0
def test_command_get_def_when_no_defs():
    set_sysargv(test_command_6)
    c = Command()
    with pytest.raises(MissingDictionaryKeyError):
        c.get_definition('bogus')
Ejemplo n.º 17
0
def test_command_get_def_when_unavailable_def():
    set_sysargv(test_command_1)
    c = Command()
    with pytest.raises(MissingDictionaryKeyError):
        c.get_definition('bogus')
def test_command_get_def_when_unavailable_def():
    set_sysargv(test_command_1)
    c = Command()
    with pytest.raises(MissingDictionaryKeyError):
        c.get_definition('bogus')