Exemplo n.º 1
0
def test_config_manage_haschanges_testmode(
    mocking_dunder_opts_test_mode_true, fake_path_response_primary_blank
):
    fake_changes = OrderedDict()
    fake_changes["fjord"] = "meow"
    result = restconf.config_manage("name", "restconf/test", "POST", fake_changes)

    assert result["result"] is None
    assert "fjord" in str(result["changes"])
    assert result["comment"] == "Config will be added"
Exemplo n.º 2
0
def test_config_manage_haschanges_realmode_200(
    mocking_dunder_opts_test_mode_false,
    fake_path_response_primary_blank,
    mocking_dunder_salt_restconf_setdata_response_200,
):
    fake_changes = OrderedDict()
    fake_changes["fjord"] = "meow"
    result = restconf.config_manage("name", "restconf/test", "POST", fake_changes)

    assert result["result"] is True
    assert type(result["changes"]) is dict
    assert "fjord" in str(result["changes"])
    assert "Successfully added config" in result["comment"]
Exemplo n.º 3
0
def test_config_manage_haschanges_realmode_404(
    mocking_dunder_opts_test_mode_false,
    fake_path_response_primary_blank,
    mocking_dunder_salt_restconf_setdata_response_404,
):
    fake_changes = OrderedDict()
    fake_changes["fjord"] = "meow"
    result = restconf.config_manage("name", "restconf/test", "POST", fake_changes)

    assert not result["result"]
    assert len(result["changes"]) == 0
    assert type(result["changes"]) is dict
    assert "failed to add / modify config" in result["comment"]
    assert "404" in result["comment"]
    assert "restconf/fakepath" in result["comment"]
Exemplo n.º 4
0
def test_config_manage_nochanges_realmode(
    mocking_dunder_opts_test_mode_false, fake_path_response_primary_blank
):
    result = restconf.config_manage("name", "restconf/test", "POST", OrderedDict())
    assert result["result"] is True
Exemplo n.º 5
0
def test_fail_config_manage_blank_name():
    # config_manage(name, path, method, config ):
    result = restconf.config_manage("", "restconf/test", "POST", "BLANKBADCONFIG")
    assert result["result"] is False
    assert "CRITICAL: name is required" in result["comment"]
Exemplo n.º 6
0
def test_fail_config_manage_blank_config():
    # config_manage(name, path, method, config ):
    result = restconf.config_manage("name", "restconf/test", "POST", "")
    assert result["result"] is False
    assert "CRITICAL: config must be an OrderedDict type" in result["comment"]
Exemplo n.º 7
0
def test_fail_config_manage_blank_path():
    # config_manage(name, path, method, config ):
    result = restconf.config_manage("name", "", "POST", "BLANKCONFIG")
    assert result["result"] is False
    assert "CRITICAL: path must not be blank" in result["comment"]