コード例 #1
0
 def test_get_first_datapoint(self, mock_get_first_dp_in_ts):
     now = utils.timestamp_to_ms("now")
     res = TS_CLIENT.retrieve(id=1).first()
     assert isinstance(res, Datapoint)
     assert Datapoint(timestamp=1, value=10) == res
     assert 0 == jsgz_load(mock_get_first_dp_in_ts.calls[1].request.body)["start"]
     assert now <= jsgz_load(mock_get_first_dp_in_ts.calls[1].request.body)["end"]
     assert 1 == jsgz_load(mock_get_first_dp_in_ts.calls[1].request.body)["limit"]
コード例 #2
0
 def test_get_count(self, mock_count_dps_in_ts):
     now = utils.timestamp_to_ms("now")
     assert 15 == TS_CLIENT.retrieve(id=1).count()
     assert "count" == jsgz_load(
         mock_count_dps_in_ts.calls[1].request.body)["aggregates"][0]
     assert 0 == jsgz_load(
         mock_count_dps_in_ts.calls[1].request.body)["start"]
     assert now <= jsgz_load(
         mock_count_dps_in_ts.calls[1].request.body)["end"]
コード例 #3
0
 def test_partitioned_list(self):
     # stop race conditions by cutting off max created time
     maxtime = utils.timestamp_to_ms(datetime(2019, 5, 25, 17, 30))
     res_flat = COGNITE_CLIENT.events.list(limit=None, type="test-data-populator", start_time={"max": maxtime})
     res_part = COGNITE_CLIENT.events.list(
         partitions=8, type="test-data-populator", start_time={"max": maxtime}, limit=None
     )
     assert len(res_flat) > 0
     assert len(res_flat) == len(res_part)
     assert {a.id for a in res_flat} == {a.id for a in res_part}
コード例 #4
0
 def test_asset(self, mock_ts_by_ids_response, mock_asset_by_ids_response):
     now = utils.timestamp_to_ms("now")
     asset = TS_CLIENT.retrieve(id=1).asset()
     assert isinstance(asset, Asset)
     assert "assetname" == asset.name