Skip to content

Commit

Permalink
rename loadconstrintfrominifile
Browse files Browse the repository at this point in the history
  • Loading branch information
payetvin committed Dec 31, 2024
1 parent ebd2664 commit 480c30f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/libs/antares/study/area/list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1201,7 +1201,7 @@ bool AreaList::loadFromFolder(const StudyLoadOptions& options)
&& ret;

const auto constraints_folder = stsFolder / "constraints" / area->id.c_str();
ret = area->shortTermStorage.LoadConstraintsFromIniFile(constraints_folder) && ret;
ret = area->shortTermStorage.loadAdditionalConstraints(constraints_folder) && ret;
}
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class STStorageInput
/// Number of enabled ST storages, ignoring disabled ST storages
std::size_t count() const;

bool LoadConstraintsFromIniFile(const std::filesystem::path& filePath);
bool loadAdditionalConstraints(const std::filesystem::path& filePath);

/// erase disabled cluster from the vector
uint removeDisabledClusters();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ static void loadHours(const std::string& hoursStr, AdditionalConstraints& additi
}
}

bool STStorageInput::LoadConstraintsFromIniFile(const fs::path& parent_path)
bool STStorageInput::loadAdditionalConstraints(const fs::path& parent_path)
{
IniFile ini;
const auto pathIni = parent_path / "additional-constraints.ini";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ BOOST_AUTO_TEST_CASE(Validate_ValidConstraints)
BOOST_CHECK(error_msg.empty());
}

BOOST_AUTO_TEST_CASE(LoadConstraintsFromIniFile_ValidFile)
BOOST_AUTO_TEST_CASE(loadAdditionalConstraints_ValidFile)
{
std::filesystem::path testPath = getFolder() / "test_data";
std::filesystem::create_directory(testPath);
Expand All @@ -561,7 +561,7 @@ BOOST_AUTO_TEST_CASE(LoadConstraintsFromIniFile_ValidFile)
cluster.id = "cluster1";
storageInput.storagesByIndex.push_back(cluster);

bool result = storageInput.LoadConstraintsFromIniFile(testPath);
bool result = storageInput.loadAdditionalConstraints(testPath);

BOOST_CHECK_EQUAL(result, true);
BOOST_CHECK_EQUAL(storageInput.storagesByIndex[0].additional_constraints.size(), 1);
Expand All @@ -571,7 +571,7 @@ BOOST_AUTO_TEST_CASE(LoadConstraintsFromIniFile_ValidFile)
std::filesystem::remove_all(testPath);
}

BOOST_AUTO_TEST_CASE(LoadConstraintsFromIniFile_InvalidHours)
BOOST_AUTO_TEST_CASE(loadAdditionalConstraints_InvalidHours)
{
std::filesystem::path testPath = getFolder() / "test_data";
std::filesystem::create_directory(testPath);
Expand All @@ -589,13 +589,13 @@ BOOST_AUTO_TEST_CASE(LoadConstraintsFromIniFile_InvalidHours)
cluster.id = "ClusterA";
storageInput.storagesByIndex.push_back(cluster);

bool result = storageInput.LoadConstraintsFromIniFile(testPath);
bool result = storageInput.loadAdditionalConstraints(testPath);
BOOST_CHECK_EQUAL(result, false);

std::filesystem::remove_all(testPath);
}

BOOST_AUTO_TEST_CASE(LoadConstraintsFromIniFile_ValidHoursFormats)
BOOST_AUTO_TEST_CASE(loadAdditionalConstraints_ValidHoursFormats)
{
std::filesystem::path testPath = getFolder() / "test_data";
std::filesystem::create_directory(testPath);
Expand All @@ -613,20 +613,20 @@ BOOST_AUTO_TEST_CASE(LoadConstraintsFromIniFile_ValidHoursFormats)
cluster.id = "cluster1";
storageInput.storagesByIndex.push_back(cluster);

bool result = storageInput.LoadConstraintsFromIniFile(testPath);
bool result = storageInput.loadAdditionalConstraints(testPath);
BOOST_CHECK_EQUAL(result, true);

std::filesystem::remove_all(testPath);
}

BOOST_AUTO_TEST_CASE(LoadConstraintsFromIniFile_MissingFile)
BOOST_AUTO_TEST_CASE(loadAdditionalConstraints_MissingFile)
{
ShortTermStorage::STStorageInput storageInput;
bool result = storageInput.LoadConstraintsFromIniFile("nonexistent_path");
bool result = storageInput.loadAdditionalConstraints("nonexistent_path");
BOOST_CHECK_EQUAL(result, true);
}

BOOST_AUTO_TEST_CASE(LoadConstraintsFromIniFile_InvalidConstraint)
BOOST_AUTO_TEST_CASE(loadAdditionalConstraints_InvalidConstraint)
{
std::filesystem::path testPath = getFolder() / "test_data";
std::filesystem::create_directory(testPath);
Expand All @@ -644,13 +644,13 @@ BOOST_AUTO_TEST_CASE(LoadConstraintsFromIniFile_InvalidConstraint)
cluster.id = "cluster1";
storageInput.storagesByIndex.push_back(cluster);

bool result = storageInput.LoadConstraintsFromIniFile(testPath);
bool result = storageInput.loadAdditionalConstraints(testPath);
BOOST_CHECK_EQUAL(result, false);

std::filesystem::remove_all(testPath);
}

BOOST_AUTO_TEST_CASE(LoadConstraintsFromIniFile_ValidRhs)
BOOST_AUTO_TEST_CASE(loadAdditionalConstraints_ValidRhs)
{
std::filesystem::path testPath = getFolder() / "test_data";
std::filesystem::create_directory(testPath);
Expand All @@ -675,7 +675,7 @@ BOOST_AUTO_TEST_CASE(LoadConstraintsFromIniFile_ValidRhs)
cluster.id = "cluster1";
storageInput.storagesByIndex.push_back(cluster);

bool result = storageInput.LoadConstraintsFromIniFile(testPath);
bool result = storageInput.loadAdditionalConstraints(testPath);

BOOST_CHECK_EQUAL(result, true);
BOOST_CHECK_EQUAL(storageInput.storagesByIndex[0].additional_constraints[0].rhs.size(),
Expand Down Expand Up @@ -718,7 +718,7 @@ BOOST_AUTO_TEST_CASE(Load2ConstraintsFromIniFile)
cluster.id = "cluster1";
storageInput.storagesByIndex.push_back(cluster);

bool result = storageInput.LoadConstraintsFromIniFile(testPath);
bool result = storageInput.loadAdditionalConstraints(testPath);

BOOST_CHECK_EQUAL(result, true);
BOOST_CHECK_EQUAL(storageInput.storagesByIndex[0].additional_constraints.size(), 2);
Expand Down Expand Up @@ -748,7 +748,7 @@ BOOST_AUTO_TEST_CASE(Load2ConstraintsFromIniFile)
std::filesystem::remove_all(testPath);
}

BOOST_AUTO_TEST_CASE(LoadConstraintsFromIniFile_MissingRhsFile)
BOOST_AUTO_TEST_CASE(loadAdditionalConstraints_MissingRhsFile)
{
std::filesystem::path testPath = getFolder() / "test_data";
std::filesystem::create_directory(testPath);
Expand All @@ -766,7 +766,7 @@ BOOST_AUTO_TEST_CASE(LoadConstraintsFromIniFile_MissingRhsFile)
cluster.id = "cluster1";
storageInput.storagesByIndex.push_back(cluster);

bool result = storageInput.LoadConstraintsFromIniFile(testPath);
bool result = storageInput.loadAdditionalConstraints(testPath);

BOOST_CHECK_EQUAL(result, true);
BOOST_CHECK_EQUAL(storageInput.storagesByIndex[0].additional_constraints[0].rhs.size(),
Expand All @@ -776,7 +776,7 @@ BOOST_AUTO_TEST_CASE(LoadConstraintsFromIniFile_MissingRhsFile)
std::filesystem::remove_all(testPath);
}

BOOST_AUTO_TEST_CASE(LoadConstraintsFromIniFile_MalformedRhsFile)
BOOST_AUTO_TEST_CASE(loadAdditionalConstraints_MalformedRhsFile)
{
std::filesystem::path testPath = getFolder() / "test_data";
std::filesystem::create_directory(testPath);
Expand All @@ -798,13 +798,13 @@ BOOST_AUTO_TEST_CASE(LoadConstraintsFromIniFile_MalformedRhsFile)
cluster.id = "ClusterA";
storageInput.storagesByIndex.push_back(cluster);

bool result = storageInput.LoadConstraintsFromIniFile(testPath);
bool result = storageInput.loadAdditionalConstraints(testPath);
BOOST_CHECK_EQUAL(result, false);

std::filesystem::remove_all(testPath);
}

BOOST_AUTO_TEST_CASE(LoadConstraintsFromIniFile_IncompleteRhsFile)
BOOST_AUTO_TEST_CASE(loadAdditionalConstraints_IncompleteRhsFile)
{
std::filesystem::path testPath = getFolder() / "test_data";
std::filesystem::create_directory(testPath);
Expand All @@ -829,7 +829,7 @@ BOOST_AUTO_TEST_CASE(LoadConstraintsFromIniFile_IncompleteRhsFile)
cluster.id = "ClusterA";
storageInput.storagesByIndex.push_back(cluster);

bool result = storageInput.LoadConstraintsFromIniFile(testPath);
bool result = storageInput.loadAdditionalConstraints(testPath);
BOOST_CHECK_EQUAL(result, false);

std::filesystem::remove_all(testPath);
Expand Down Expand Up @@ -895,7 +895,7 @@ BOOST_DATA_TEST_CASE(Validate_AllVariableOperatorCombinationsFromFile,
storageInput.storagesByIndex.push_back(cluster);

// Load constraints from the `.ini` file
bool result = storageInput.LoadConstraintsFromIniFile(testPath);
bool result = storageInput.loadAdditionalConstraints(testPath);

// Assertions
BOOST_CHECK_EQUAL(result, true);
Expand Down

0 comments on commit 480c30f

Please sign in to comment.