-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8667044
commit 11c3833
Showing
1 changed file
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import unittest | ||
|
||
import ams | ||
|
||
|
||
class TestOModelWrappers(unittest.TestCase): | ||
""" | ||
Test wrappers in module `omodel`. | ||
""" | ||
|
||
def setUp(self) -> None: | ||
self.ss = ams.load(ams.get_case("matpower/case5.m"), | ||
setup=True, | ||
default_config=True, | ||
no_output=True, | ||
) | ||
|
||
def test_ensure_symbols(self): | ||
""" | ||
Test `ensure_symbols` wrapper. | ||
""" | ||
self.assertFalse(self.ss.DCOPF._syms, "Symbols should not be ready before generation!") | ||
self.ss.DCOPF.pd.parse() | ||
self.assertTrue(self.ss.DCOPF._syms, "Symbols should be ready after generation!") | ||
|
||
def test_ensure_mats_and_parsed(self): | ||
""" | ||
Test `ensure_mats_and_parsed` wrapper. | ||
""" | ||
self.assertFalse(self.ss.mats.initialized, "MatProcessor should not be initialized before initialization!") | ||
self.assertFalse(self.ss.DCOPF.om.parsed, "OModel should be parsed after parsing!") | ||
self.ss.DCOPF.pd.evaluate() | ||
self.assertTrue(self.ss.mats.initialized, "MatProcessor should be initialized after parsing!") | ||
self.assertTrue(self.ss.DCOPF.om.parsed, "OModle should be parsed after parsing!") | ||
|
||
|
||
class TestOModel(unittest.TestCase): | ||
""" | ||
Test class `OModel`. | ||
""" | ||
|
||
def setUp(self) -> None: | ||
self.ss = ams.load(ams.get_case("matpower/case5.m"), | ||
setup=True, | ||
default_config=True, | ||
no_output=True, | ||
) | ||
|
||
def test_initialized(self): | ||
""" | ||
Test `OModel` initialization. | ||
""" | ||
self.assertFalse(self.ss.DCOPF.om.initialized, "OModel shoud not be initialized before initialziation!") | ||
self.ss.DCOPF.om.init() | ||
self.assertTrue(self.ss.DCOPF.om.initialized, "OModel should be initialized!") | ||
|
||
def test_uninitialized_after_nonparametric_update(self): | ||
""" | ||
Test `OModel` initialization after nonparametric update. | ||
""" | ||
self.ss.DCOPF.om.init() | ||
self.assertTrue(self.ss.DCOPF.om.initialized, "OModel should be initialized after initialization!") | ||
self.ss.DCOPF.update('ug') | ||
self.assertTrue(self.ss.DCOPF.om.initialized, "OModel should be initialized after nonparametric update!") |