def test_update_bad(datasource): # noqa: F811 """Do updates fail to work on bogus taskmanager as expected""" metadata_row = datasource.get_metadata( taskmanager_id=1, generation_id=1, key="my_test_key", ) header_row = datasource.get_header( taskmanager_id=1, generation_id=1, key="my_test_key", ) with pytest.raises(Exception): datasource.update( taskmanager_id=100, generation_id=1, key="my_test_key", value=b"I changed IT", header=Header( header_row[0], create_time=header_row[4], expiration_time=header_row[5], scheduled_create_time=header_row[6], creator=header_row[7], schema_id=header_row[8], ), metadata=Metadata( metadata_row[0], state=metadata_row[4], generation_id=metadata_row[2], generation_time=metadata_row[5], missed_update_count=metadata_row[6], ), )
def test_update(datasource): # noqa: F811 """Do updates work as expected""" metadata_row = datasource.get_metadata( taskmanager_id=1, generation_id=1, key="my_test_key", ) header_row = datasource.get_header( taskmanager_id=1, generation_id=1, key="my_test_key", ) datasource.update( taskmanager_id=1, generation_id=1, key="my_test_key", value=b"I changed IT", header=Header( header_row[0], create_time=header_row[4], expiration_time=header_row[5], scheduled_create_time=header_row[6], creator=header_row[7], schema_id=header_row[8], ), metadata=Metadata( metadata_row[0], state=metadata_row[4], generation_id=metadata_row[2], generation_time=metadata_row[5], missed_update_count=metadata_row[6], ), ) result1 = datasource.get_dataproduct( taskmanager_id=1, generation_id=1, key="my_test_key", ) assert result1 == b"I changed IT"