Skip to content

Commit

Permalink
tests: skip tests
Browse files Browse the repository at this point in the history
  • Loading branch information
doctrino committed Nov 7, 2024
1 parent 880e8d0 commit 316c8d8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 15 deletions.
8 changes: 6 additions & 2 deletions cognite/neat/_rules/exporters/_rules2dms.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,16 @@ def _create_exclude_set(self):
def export(self, rules: DMSRules) -> DMSSchema:
return rules.as_schema(include_pipeline=self.export_pipeline, instance_space=self.instance_space)

def delete_from_cdf(self, rules: DMSRules, client: CogniteClient, dry_run: bool = False) -> Iterable[UploadResult]:
def delete_from_cdf(
self, rules: DMSRules, client: CogniteClient, dry_run: bool = False, skip_space: bool = False
) -> Iterable[UploadResult]:
to_export = self._prepare_exporters(rules, client)

# we need to reverse order in which we are picking up the items to delete
# as they are sorted in the order of creation and we need to delete them in reverse order
for items, loader in reversed(to_export):
if skip_space and isinstance(loader, SpaceLoader):
continue
item_ids = loader.get_ids(items)
existing_items = loader.retrieve(item_ids)
existing_ids = loader.get_ids(existing_items)
Expand Down Expand Up @@ -168,7 +172,7 @@ def export_to_cdf_iterable(

result_by_name = {}
if self.existing_handling == "force":
for delete_result in self.delete_from_cdf(rules, client, dry_run):
for delete_result in self.delete_from_cdf(rules, client, dry_run, skip_space=True):
result_by_name[delete_result.name] = delete_result

redeploy_data_model = False
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,18 +170,22 @@ def test_export_alice_to_cdf(self, cognite_client: CogniteClient, alice_rules: D
uploaded = exporter.export_to_cdf_iterable(rules, cognite_client, dry_run=False)
uploaded_by_name = {entity.name: entity for entity in uploaded}

assert uploaded_by_name["containers"].success == len(rules.containers)
assert uploaded_by_name["containers"].success == len(rules.containers) * 2 # 2 x due to delete and create
assert uploaded_by_name["containers"].failed == 0

assert uploaded_by_name["views"].success == len(rules.views)
assert uploaded_by_name["views"].success == len(rules.views) * 2 # 2 x due to delete and create
assert uploaded_by_name["views"].failed == 0

assert uploaded_by_name["data_models"].success == 1
assert uploaded_by_name["data_models"].success == 1 * 2 # 2 x due to delete and create
assert uploaded_by_name["data_models"].failed == 0

assert uploaded_by_name["spaces"].success == 1
assert uploaded_by_name["spaces"].success == 1 # Space is not deleted
assert uploaded_by_name["spaces"].failed == 0

@pytest.mark.skip(
"We are not exposing the functionality any more. "
"It is up for discussion if we should keep it. Does the test is not maintained."
)
def test_export_pipeline_populate_and_retrieve_data(
self, cognite_client: CogniteClient, table_example: InformationRules, table_example_data: dict[str, list[str]]
) -> None:
Expand Down Expand Up @@ -259,13 +263,14 @@ def test_export_olav_dms_to_cdf(self, cognite_client: CogniteClient, olav_dms_ru
uploaded = exporter.export_to_cdf_iterable(rules, cognite_client, dry_run=False)
uploaded_by_name = {entity.name: entity for entity in uploaded}

assert uploaded_by_name["containers"].success == len(rules.containers)
# We have to double the amount of entities due to the delete and create
assert uploaded_by_name["containers"].success == len(rules.containers) * 2
assert uploaded_by_name["containers"].failed == 0

assert uploaded_by_name["views"].success == len(rules.views)
assert uploaded_by_name["views"].success == len(rules.views) * 2
assert uploaded_by_name["views"].failed == 0

assert uploaded_by_name["data_models"].success == 1
assert uploaded_by_name["data_models"].success == 1 * 2
assert uploaded_by_name["data_models"].failed == 0

assert uploaded_by_name["spaces"].success == 1
Expand All @@ -292,13 +297,14 @@ def test_export_svein_harald_dms_to_cdf(
uploaded = exporter.export_to_cdf(rules, cognite_client, dry_run=False)
uploaded_by_name = {entity.name: entity for entity in uploaded}

assert uploaded_by_name["containers"].success == len(rules.containers)
# We have to double the amount of entities due to the delete and create
assert uploaded_by_name["containers"].success == len(rules.containers) * 2
assert uploaded_by_name["containers"].failed == 0

assert uploaded_by_name["views"].success == len(schema.views)
assert uploaded_by_name["views"].success == len(schema.views) * 2
assert uploaded_by_name["views"].failed == 0

assert uploaded_by_name["data_models"].success == 1
assert uploaded_by_name["data_models"].success == 1 * 2
assert uploaded_by_name["data_models"].failed == 0

assert uploaded_by_name["spaces"].success == 1
Expand Down Expand Up @@ -355,13 +361,14 @@ def test_export_olav_updated_dms_to_cdf(
uploaded = exporter.export_to_cdf_iterable(rules, cognite_client, dry_run=False)
uploaded_by_name = {entity.name: entity for entity in uploaded}

assert uploaded_by_name["containers"].success == len(schema.containers)
# We have to double the amount of entities due to the delete and create
assert uploaded_by_name["containers"].success == len(schema.containers) * 2
assert uploaded_by_name["containers"].failed == 0

assert uploaded_by_name["views"].success == len(schema.views)
assert uploaded_by_name["views"].success == len(schema.views) * 2
assert uploaded_by_name["views"].failed == 0

assert uploaded_by_name["data_models"].success == 1
assert uploaded_by_name["data_models"].success == 1 * 2
assert uploaded_by_name["data_models"].failed == 0

assert uploaded_by_name["spaces"].success == 1
Expand Down

0 comments on commit 316c8d8

Please sign in to comment.