-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added pytests for Registry and MepoComponent classes
- Loading branch information
1 parent
b75c5a6
commit cb985f8
Showing
3 changed files
with
103 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
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,71 @@ | ||
import os | ||
|
||
from mepo.component import stylize_local_path | ||
from mepo.component import MepoComponent | ||
from mepo.registry import Registry | ||
from mepo.utilities.version import MepoVersion | ||
|
||
from _pytest.assertion import truncate | ||
|
||
truncate.DEFAULT_MAX_LINES = 9999 | ||
truncate.DEFAULT_MAX_CHARS = 9999 | ||
|
||
TEST_DIR = os.path.dirname(os.path.realpath(__file__)) | ||
|
||
|
||
def get_registry(): | ||
registry = os.path.join(TEST_DIR, "input", "components.yaml") | ||
return Registry(registry).read_file() | ||
|
||
|
||
def get_fvdycore_component(): | ||
comp = MepoComponent() | ||
comp.name = "fvdycore" | ||
comp.local = "./src/Components/@FVdycoreCubed_GridComp/@fvdycore" | ||
comp.remote = "[email protected]:GEOS-ESM/GFDL_atmos_cubed_sphere.git" | ||
comp.version = MepoVersion(name="geos/v1.3.0", type="t", detached=True) | ||
comp.sparse = None | ||
comp.develop = "geos/develop" | ||
comp.recurse_submodules = None | ||
comp.fixture = False | ||
comp.ignore_submodules = None | ||
return comp | ||
|
||
|
||
def get_fvdycore_serialized(): | ||
return { | ||
"name": "fvdycore", | ||
"local": "./src/Components/@FVdycoreCubed_GridComp/@fvdycore", | ||
"remote": "[email protected]:GEOS-ESM/GFDL_atmos_cubed_sphere.git", | ||
"version": ["geos/v1.3.0", "t", True], | ||
"sparse": None, | ||
"develop": "geos/develop", | ||
"recurse_submodules": None, | ||
"fixture": False, | ||
"ignore_submodules": None, | ||
} | ||
|
||
|
||
def test_stylize_local_path(): | ||
local_path = "./src/Shared/@GMAO_Shared/@GEOS_Util" | ||
output = stylize_local_path(local_path, None) | ||
assert output == local_path | ||
output = stylize_local_path(local_path, "prefix") | ||
assert output == local_path | ||
output = stylize_local_path(local_path, "naked") | ||
assert output == "./src/Shared/@GMAO_Shared/GEOS_Util" | ||
output = stylize_local_path(local_path, "postfix") | ||
assert output == "./src/Shared/@GMAO_Shared/GEOS_Util@" | ||
|
||
|
||
def test_MepoComponent(): | ||
registry = get_registry() | ||
complist = list() | ||
for name, comp in registry.items(): | ||
if name == "fvdycore": | ||
fvdycore = MepoComponent().registry_to_component(name, comp, None) | ||
# comp = MepoComponent().registry_to_component(name, comp, None) | ||
# assert comp == get_fvdycore_component() | ||
# complist.append(comp) | ||
assert fvdycore == get_fvdycore_component() | ||
assert fvdycore.serialize() == get_fvdycore_serialized() |
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,19 @@ | ||
import os | ||
|
||
from mepo.registry import Registry | ||
|
||
TEST_DIR = os.path.dirname(os.path.realpath(__file__)) | ||
|
||
|
||
def get_ecbuild_details(): | ||
return { | ||
"local": "./@cmake/@ecbuild", | ||
"remote": "../ecbuild.git", | ||
"tag": "geos/v1.2.0", | ||
} | ||
|
||
|
||
def test_registry(): | ||
registry = os.path.join(TEST_DIR, "input", "components.yaml") | ||
a = Registry(registry).read_file() | ||
assert a["ecbuild"] == get_ecbuild_details() |