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"
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"]
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"]
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
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"]
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"]
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"]