Skip to content

Commit

Permalink
Don't use blazegraph in unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkleiven committed Feb 16, 2024
1 parent 2057ee6 commit 48214ac
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 38 deletions.
26 changes: 6 additions & 20 deletions tests/t_utils/entsoe_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ def split_tpsvssh(fname: Path) -> tuple[list[str], list[str]]:


@functools.lru_cache
def federated_micro_t1_nl_bg() -> t_common.ModelTest:
def federated_micro_t1() -> t_common.ModelTest:
model = None
url = t_common.blazegraph_url()
url = t_common.rdf4j_url()
try:
tpsvssh_client = new_repo_blazegraph(url, "federated_micro_t1_nl_tpsvssh", "http")
eq_client = new_repo_blazegraph(url, "federated_micro_t1_nl_eq", "http")
tpsvssh_client = t_common.init_repo_rdf4j(url, "federated_micro_t1_nl_tpsvssh")
eq_client = t_common.init_repo_rdf4j(url, "federated_micro_t1_nl_eq")

adaptor = XmlModelAdaptor.from_folder(this_dir.parent / "data/micro")
adaptor.adapt(eq_client.service_cfg.url)
Expand Down Expand Up @@ -106,19 +106,6 @@ def micro_t1_nl() -> t_common.ModelTest:
return t_common.ModelTest(model)


@functools.lru_cache
def micro_t1_nl_bg() -> t_common.ModelTest:
model = None
try:
url = t_common.blazegraph_url()
client = new_repo_blazegraph(url, "micro_t1_nl", "http")
upload_micro_model(client)
model = SingleClientModel(client)
except Exception:
logger.exception("Failed to get single client model")
return t_common.ModelTest(model)


@functools.lru_cache
def small_grid_model(url: str, api: RestApi) -> t_common.ModelTest:
def bg_http(url: str, name: str) -> GraphDBClient:
Expand Down Expand Up @@ -152,10 +139,9 @@ def bg_http(url: str, name: str) -> GraphDBClient:


def micro_models() -> list[t_common.ModelTest]:
return [micro_t1_nl(), micro_t1_nl_bg(), federated_micro_t1_nl_bg()]
return [micro_t1_nl(), federated_micro_t1()]


def smallgrid_models() -> list[t_common.ModelTest]:
bg_model = small_grid_model(t_common.blazegraph_url(), RestApi.BLAZEGRAPH)
rdfj4_model = small_grid_model(t_common.rdf4j_url(), RestApi.RDF4J)
return [rdfj4_model, bg_model]
return [rdfj4_model]
12 changes: 0 additions & 12 deletions tests/test_blazegraph.py

This file was deleted.

10 changes: 5 additions & 5 deletions tests/test_model_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ async def get_node_consistency_test_data(


async def collect_node_consistency_data() -> list[NodeConsistencyData]:
test_models = [t_custom.combined_model(), t_entsoe.micro_t1_nl_bg()]
test_models = [t_custom.combined_model(), t_entsoe.micro_t1_nl()]
if any(m.model is None and m.must_run_in_ci and os.getenv("CI") for m in test_models):
pytest.fail("Model that must run in CI is None")
res = await asyncio.gather(*[get_node_consistency_test_data(m.model) for m in test_models])
Expand All @@ -92,15 +92,15 @@ def nc_data() -> CONSISTENCY_DATA:
for node data
"""
res = asyncio.run(collect_node_consistency_data())
return {"model": res[0], "t_entsoe.micro_t1_nl_bg": res[1]}
return {"model": res[0]}


def skip_on_missing(data: CONSISTENCY_DATA, model_name: str):
if not data:
pytest.skip(f"No data collected for {model_name}")


@pytest.mark.parametrize("model_name", ["model", "t_entsoe.micro_t1_nl_bg"])
@pytest.mark.parametrize("model_name", ["model"])
def test_node_consistency(nc_data: CONSISTENCY_DATA, model_name: str):
data = nc_data[model_name]
skip_on_missing(data, model_name)
Expand All @@ -116,7 +116,7 @@ def test_node_consistency(nc_data: CONSISTENCY_DATA, model_name: str):
assert set(df["node"]).issubset(mrids), msg


@pytest.mark.parametrize("model_name", ["model", "t_entsoe.micro_t1_nl_bg"])
@pytest.mark.parametrize("model_name", ["model"])
def test_two_or_three_winding(nc_data: CONSISTENCY_DATA, model_name: str):
"""
Ensure that a transformer is either a two winding transformer or three winding
Expand All @@ -129,7 +129,7 @@ def test_two_or_three_winding(nc_data: CONSISTENCY_DATA, model_name: str):
assert len(set(two_w).intersection(three_w)) == 0


@pytest.mark.parametrize("model_name", ["model", "t_entsoe.micro_t1_nl_bg"])
@pytest.mark.parametrize("model_name", ["model"])
def test_swing_bus_consistency(nc_data: CONSISTENCY_DATA, model_name: str):
data = nc_data[model_name]
skip_on_missing(data, model_name)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_value_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

@pytest.mark.asyncio
async def test_subj_conversion():
tm = t_entsoe.micro_t1_nl_bg()
tm = t_entsoe.micro_t1_nl()
t_common.check_model(tm)
model = tm.model
model2 = deepcopy(model)
Expand Down

0 comments on commit 48214ac

Please sign in to comment.