def test_should_save_preferences(self, mock_load_config_file): config_path = "my_config_file.yaml" settings.save_config_file_preferences(config_path) assert settings["config_path"].endswith( "my_config_file.yaml") mock_load_config_file.assert_called_with( "my_config_file.yaml")
def test_should_save_preferences(self): with open(DEFAULT_CONFIG_PATH, "w") as out_file: out_file.write("template: path/template.jinja") settings.save_config_file_preferences() assert settings["template"] == "path/template.jinja" os.remove(DEFAULT_CONFIG_PATH)
def test_should_save_preferences(self): with open(DEFAULT_CONFIG_PATH, "w") as out_file: out_file.write("reporter: html") settings.save_config_file_preferences() assert settings["reporter"] == "html" os.remove(DEFAULT_CONFIG_PATH)
def test_should_save_preferences_3( self, mock_doesnt_have_local_config_file, mock_has_global_config_file, mock_load_config_file, ): settings.save_config_file_preferences() assert settings["config_path"].endswith("scanapi/scanapi.conf") assert mock_load_config_file.called
def test_should_raise_exception(self): with raises(FileNotFoundError) as excinfo: config_path = "invalid/my_config_file.yaml" settings.save_config_file_preferences(config_path) assert ( str(excinfo.value) == "[Errno 2] No such file or directory: 'invalid/my_config_file.yaml'" )
def test_should_save_preferences(self): config_path = "my_config_file.yaml" with open(config_path, "w") as out_file: out_file.write("template: template.jinja") settings.save_config_file_preferences(config_path) assert settings["template"] == "template.jinja" os.remove(config_path)
def test_should_save_preferences(self): config_path = "my_config_file.yaml" with open(config_path, "w") as out_file: out_file.write("reporter: html") settings.save_config_file_preferences(config_path) assert settings["reporter"] == "html" os.remove(config_path)
def test_should_save_preferences_2( self, mock_has_local_config_file, mock_load_config_file ): settings.save_config_file_preferences() assert settings["config_path"].endswith("./scanapi.conf") mock_load_config_file.assert_called_with("./scanapi.conf")
def test_should_not_change_preferences(self): settings.save_config_file_preferences() assert settings["spec_path"] == "path/spec-path.yaml"
def test_should_not_change_preferences(self): settings.save_config_file_preferences() assert settings["reporter"] == "markdown"