def test_provider_download_algorithm(ddo_algorithm): config = ExampleConfig.get_config() publisher_instance = get_publisher_instance(True, False, False) provider = publisher_instance.main_account consumer_instance = get_consumer_instance(True, False, False) consumer = consumer_instance.main_account metadata = ddo_algorithm["service"][0] # consumer creates algorithm asset (for a compute job) ddo = consumer_instance.assets.create( metadata["attributes"], consumer, providers=[provider.address] ) assert ddo # provider downloads the asset service_agreement = ddo.get_service("access") assert publisher_instance.assets.download( ddo.did, service_agreement.index, consumer, config.downloads_path ) consumer_instance.assets.retire(ddo.did)
def test_consumer_download_compute(metadata): config = ExampleConfig.get_config() publisher_instance = get_publisher_instance(True, False, False) publisher = publisher_instance.main_account consumer_instance = get_consumer_instance(True, False, False) consumer = consumer_instance.main_account # publisher creates compute asset ddo = publisher_instance.assets.create_compute(metadata, publisher) assert ddo # consumer orders compute asset service_agreement = ddo.get_service("compute") _agreement_id = consumer_instance.assets.order( ddo.did, service_agreement.index, consumer, consumer ) # consumer tries to download the asset with pytest.raises(ValueError): consumer_instance.assets.download( ddo.did, service_agreement.index, consumer, config.downloads_path ) publisher_instance.assets.retire(ddo.did)
def consumer_instance_no_init(): return get_consumer_instance(False, False, False)
def consumer_instance_gateway(): return get_consumer_instance(use_gateway_mock=False, use_ss_mock=False)
def consumer_instance(): return get_consumer_instance()