22# Copyright 2023 Ocean Protocol Foundation
33# SPDX-License-Identifier: Apache-2.0
44#
5+ import os
56from unittest .mock import Mock , patch
67
78from freezegun import freeze_time
@@ -123,7 +124,9 @@ def test_purgatory_retrieve_new_list(events_object):
123124 the_response .status_code = 200
124125 the_response .json .return_value = [{"did" : "some_did" , "reason" : "some_reason" }]
125126 mock .return_value = the_response
126- assert purgatory .retrieve_new_list ("env" ) == {("some_did" , "some_reason" )}
127+ assert purgatory .retrieve_new_list ("ASSET_PURGATORY_URL" ) == {
128+ ("some_did" , "some_reason" )
129+ }
127130
128131 with patch ("requests.get" ) as mock :
129132 the_response = Mock (spec = Response )
@@ -132,6 +135,24 @@ def test_purgatory_retrieve_new_list(events_object):
132135 assert purgatory .retrieve_new_list ("env" ) == set ()
133136
134137
138+ def test_purgatory_retrieve_account_list (events_object , monkeypatch ):
139+ # set account purgatory filtering for accounts
140+ monkeypatch .setenv (
141+ "ACCOUNT_PURGATORY_URL" ,
142+ "https://raw.githubusercontent.com/oceanprotocol/list-purgatory/main/list-accounts.json" ,
143+ )
144+ purgatory = Purgatory (events_object ._es_instance )
145+
146+ result = purgatory .retrieve_new_list ("ACCOUNT_PURGATORY_URL" )
147+ assert result
148+
149+ filter_by_address = {
150+ x [1 ] for x in result if x [0 ] == "0xAD23fC9D943018C34aC55E8DA29AF700A2Fd0FeB"
151+ }
152+ assert len (filter_by_address ) == 1
153+ assert list (filter_by_address )[0 ] == "bad actor"
154+
155+
135156def test_failures (events_object ):
136157 purgatory = Purgatory (events_object ._es_instance )
137158 with patch ("aquarius.app.es_instance.ElasticsearchInstance.update" ) as mock :
0 commit comments