diff --git a/src/solver/modeler/loadFiles/include/antares/solver/modeler/loadFiles/loadFiles.h b/src/solver/modeler/loadFiles/include/antares/solver/modeler/loadFiles/loadFiles.h index 61c417f585..63ab4bb732 100644 --- a/src/solver/modeler/loadFiles/include/antares/solver/modeler/loadFiles/loadFiles.h +++ b/src/solver/modeler/loadFiles/include/antares/solver/modeler/loadFiles/loadFiles.h @@ -22,6 +22,7 @@ #pragma once #include +#include #include #include @@ -32,4 +33,6 @@ namespace Antares::Solver::LoadFiles Study::SystemModel::System loadSystem(const std::filesystem::path& studyPath, const std::vector& libraries); +std::vector loadLibraries(const std::filesystem::path& studyPath); + } // namespace Antares::Solver::LoadFiles diff --git a/src/solver/modeler/loadFiles/readLibraries.cpp b/src/solver/modeler/loadFiles/readLibraries.cpp index d71615f080..33fefacc23 100644 --- a/src/solver/modeler/loadFiles/readLibraries.cpp +++ b/src/solver/modeler/loadFiles/readLibraries.cpp @@ -46,7 +46,7 @@ std::vector loadLibraries(const fs::path& studyPath const fs::path directoryPath = studyPath / "input" / "model-libraries"; for (const auto& entry: fs::directory_iterator(directoryPath)) { - if (entry.path().extension() != "yml") + if (entry.path().extension() != ".yml") { logs.info() << "File ignored because of wrong extension: " << entry.path(); continue; diff --git a/src/tests/src/solver/modeler/loadFiles/testLoadModelerFiles.cpp b/src/tests/src/solver/modeler/loadFiles/testLoadModelerFiles.cpp index 8512eeba33..d3fe9c4c82 100644 --- a/src/tests/src/solver/modeler/loadFiles/testLoadModelerFiles.cpp +++ b/src/tests/src/solver/modeler/loadFiles/testLoadModelerFiles.cpp @@ -31,24 +31,41 @@ BOOST_AUTO_TEST_SUITE(read_modeler_parameters) -BOOST_AUTO_TEST_CASE(all_properties_set) +namespace fs = std::filesystem; + +struct FixtureLoadFile +{ + fs::path studyPath; + fs::path inputPath; + fs::path libraryDirPath; + + FixtureLoadFile() + { + studyPath = CREATE_TMP_DIR_BASED_ON_TEST_NAME(); + inputPath = createFolder(studyPath, "input"); + libraryDirPath = createFolder(inputPath, "model-libraries"); + } + + ~FixtureLoadFile() + { + fs::remove_all(studyPath); + } +}; + +BOOST_FIXTURE_TEST_CASE(read_one_lib_file, FixtureLoadFile) { - /* const auto working_tmp_dir = CREATE_TMP_DIR_BASED_ON_TEST_NAME(); */ - /* const auto fileP = working_tmp_dir / "parameters.yaml"; */ - /* { */ - /* std::ofstream param(fileP); */ - /* param << R"( */ - /* solver: sirius */ - /* solver-logs: false */ - /* solver-parameters: PRESOLVE 1 */ - /* no-output: true)"; */ - /* } */ - - /* auto params = Antares::Solver::parseModelerParameters(fileP); */ - /* BOOST_CHECK_EQUAL(params.solver, "sirius"); */ - /* BOOST_CHECK_EQUAL(params.solverLogs, false); */ - /* BOOST_CHECK_EQUAL(params.solverParameters, "PRESOLVE 1"); */ - /* BOOST_CHECK_EQUAL(params.noOutput, true); */ + std::ofstream libStream(libraryDirPath / "simple.yml"); + libStream << R"( + library: + id: lib_id + description: lib_description + port-types: [] + models: [] + )"; + libStream.close(); + + auto libraries = Antares::Solver::LoadFiles::loadLibraries(studyPath); + /* BOOST_CHECK_EQUAL(libraries[0].Id(), "lib_id"); */ } BOOST_AUTO_TEST_SUITE_END() diff --git a/src/tests/src/utils/files-system.cpp b/src/tests/src/utils/files-system.cpp index f6097ee82b..e8d6163ea7 100644 --- a/src/tests/src/utils/files-system.cpp +++ b/src/tests/src/utils/files-system.cpp @@ -10,7 +10,7 @@ fs::path generateAndCreateDirName(const std::string& dirName) return working_dir; } -void createFolder(const std::string& path, const std::string& folder_name) +fs::path createFolder(const std::string& path, const std::string& folder_name) { fs::path folder_path = fs::path(path.c_str()) / folder_name.c_str(); @@ -22,6 +22,8 @@ void createFolder(const std::string& path, const std::string& folder_name) { std::cerr << "Exception creating folder '" + folder_name + "': " + e.what() + "\n"; } + + return folder_path; } void createFile(const std::string& folder_path, const std::string& file_name) diff --git a/src/tests/src/utils/files-system.h b/src/tests/src/utils/files-system.h index 092b498350..9ad4503e54 100644 --- a/src/tests/src/utils/files-system.h +++ b/src/tests/src/utils/files-system.h @@ -31,6 +31,6 @@ std::filesystem::path generateAndCreateDirName(const std::string&); -void createFolder(const std::string& path, const std::string& folder_name); +std::filesystem::path createFolder(const std::string& path, const std::string& folder_name); void createFile(const std::string& folder_path, const std::string& file_name); void removeFolder(std::string& path, std::string& folder_name);