def test_assets_update_object(self): assert isinstance( AssetUpdate(1).description.set("").description.set( None).external_id.set("1").external_id.set(None).metadata.set( {}).metadata.set(None).name.set("").name.set( None).source.set(1).source.set(None), AssetUpdate, )
def test_update_labels(self, mock_assets_response): ASSETS_API.update([AssetUpdate(id=1).labels.add(["PUMP", "ROTATING_EQUIPMENT"]).labels.remove(["VALVE"])]) request_body = json.loads(mock_assets_response.calls[0].request.body)["items"][0]["update"] expected = { "labels": { "add": [{"externalId": "PUMP"}, {"externalId": "ROTATING_EQUIPMENT"}], "remove": [{"externalId": "VALVE"}], } } assert request_body == expected
def test_assets_update_object(self): assert isinstance( AssetUpdate(1) .description.set("") .description.set(None) .external_id.set("1") .external_id.set(None) .metadata.set({}) .metadata.set(None) .labels.add(["PUMP"]) .labels.remove(["VALVE"]) .name.set("") .name.set(None) .source.set(1) .source.set(None) .data_set_id.set(123), AssetUpdate, )
def test_update_multiple(self, mock_assets_response): res = ASSETS_API.update([AssetUpdate(id=1).description.set("blabla")]) assert isinstance(res, AssetList) assert mock_assets_response.calls[0].response.json( )["items"] == res.dump(camel_case=True)
def test_update_with_update_class(self, mock_assets_response): res = ASSETS_API.update(AssetUpdate(id=1).description.set("blabla")) assert isinstance(res, Asset) assert mock_assets_response.calls[0].response.json( )["items"][0] == res.dump(camel_case=True)
def test_update_labels_using_deprecated_methods(self, mock_assets_response): ASSETS_API.update([AssetUpdate(id=1).add_label("PUMP")]) request_body = json.loads(mock_assets_response.calls[0].request.body)["items"][0]["update"] expected = {"labels": {"add": [{"externalId": "PUMP"}]}} assert request_body == expected