Skip to content

Commit

Permalink
tests: added failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
doctrino committed Dec 4, 2024
1 parent fa7f991 commit ca8d878
Showing 1 changed file with 61 additions and 1 deletion.
62 changes: 61 additions & 1 deletion tests/tests_integration/test_api/test_sequences.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import unittest
from unittest import mock

import pytest
Expand All @@ -14,7 +15,12 @@
SequenceUpdate,
filters,
)
from cognite.client.data_classes.sequences import SequenceProperty, SortableSequenceProperty
from cognite.client.data_classes.sequences import (
SequenceColumnWrite,
SequenceProperty,
SequenceWrite,
SortableSequenceProperty,
)
from cognite.client.exceptions import CogniteNotFoundError
from cognite.client.utils._text import random_string
from tests.utils import set_request_limit
Expand Down Expand Up @@ -329,3 +335,57 @@ def test_aggregate_unique_metadata_keys(self, cognite_client: CogniteClient, seq
assert {tuple(item.value["property"]) for item in result} >= {
("metadata", key.casefold()) for a in sequence_list for key in a.metadata or []
}

def test_upsert_sequence(self, cognite_client: CogniteClient) -> None:
original_sequence = SequenceWrite(
external_id=f"upsert_sequence_{random_string(5)}",
columns=[
SequenceColumnWrite(
description="KW Description", name="KW Name", value_type="Double", external_id="kw_seq_01"
),
],
description="Description of the Test Sequence",
name="Test Sequence Name",
)
upsert = SequenceWrite(
external_id=original_sequence.external_id,
columns=[
SequenceColumnWrite(
description="KW Description",
name="KW Name",
value_type="Double",
external_id="kw_seq_01",
metadata={},
),
SequenceColumnWrite(
description="PW Description",
name="PW Name",
value_type="Double",
external_id="pw_seq_01",
metadata={},
),
SequenceColumnWrite(
description="LW Description",
name="LW Name",
value_type="Double",
external_id="lw_seq_01",
metadata={},
),
],
description="Description of the Test Sequence",
name="Test Sequence Name",
)

created: Sequence | None = None
try:
created = cognite_client.sequences.create(original_sequence)

upserted = cognite_client.sequences.upsert(upsert)

retrieved = cognite_client.sequences.retrieve(external_id=upserted.external_id)

assert retrieved is not None
unittest.TestCase().assertCountEqual(retrieved.as_write().columns.dump(), upsert.columns.dump())
finally:
if created:
cognite_client.sequences.delete(external_id=created.external_id, ignore_unknown_ids=True)

0 comments on commit ca8d878

Please sign in to comment.