<s> """<STR_LIT>""" <EOL> import copy <EOL> from openstackclient . api import api <EOL> from openstackclient . api import utils as api_utils <EOL> from openstackclient . tests . api import fakes as api_fakes <EOL> class TestBaseAPIFilter ( api_fakes . TestSession ) : <EOL> """<STR_LIT>""" <EOL> def setUp ( self ) : <EOL> super ( TestBaseAPIFilter , self ) . setUp ( ) <EOL> self . api = api . BaseAPI ( <EOL> session = self . sess , <EOL> endpoint = self . BASE_URL , <EOL> ) <EOL> self . input_list = [ <EOL> api_fakes . RESP_ITEM_1 , <EOL> api_fakes . RESP_ITEM_2 , <EOL> api_fakes . RESP_ITEM_3 , <EOL> ] <EOL> def test_simple_filter_none ( self ) : <EOL> output = api_utils . simple_filter ( <EOL> ) <EOL> self . assertIsNone ( output ) <EOL> def test_simple_filter_no_attr ( self ) : <EOL> output = api_utils . simple_filter ( <EOL> copy . deepcopy ( self . input_list ) , <EOL> ) <EOL> self . assertEqual ( self . input_list , output ) <EOL> def test_simple_filter_attr_only ( self ) : <EOL> output = api_utils . simple_filter ( <EOL> copy . deepcopy ( self . input_list ) , <EOL> attr = '<STR_LIT:status>' , <EOL> ) <EOL> self . assertEqual ( self . input_list , output ) <EOL> def test_simple_filter_attr_value ( self ) : <EOL> output = api_utils . simple_filter ( <EOL> copy . deepcopy ( self . input_list ) , <EOL> attr = '<STR_LIT:status>' , <EOL> value = '<STR_LIT>' , <EOL> ) <EOL> self . assertEqual ( [ ] , output ) <EOL> output = api_utils . simple_filter ( <EOL> copy . deepcopy ( self . input_list ) , <EOL> attr = '<STR_LIT:status>' , <EOL> value = '<STR_LIT>' , <EOL> ) <EOL> self . assertEqual ( <EOL> [ api_fakes . RESP_ITEM_1 , api_fakes . RESP_ITEM_3 ] , <EOL> output , <EOL> ) <EOL> output = api_utils . simple_filter ( <EOL> copy . deepcopy ( self . input_list ) , <EOL> attr = '<STR_LIT>' , <EOL> value = '<STR_LIT>' , <EOL> ) <EOL> self . assertEqual ( [ ] , output ) <EOL> def test_simple_filter_prop_attr_only ( self ) : <EOL> output = api_utils . simple_filter ( <EOL> copy . deepcopy ( self . input_list ) , <EOL> attr = '<STR_LIT:b>' , <EOL> property_field = '<STR_LIT>' , <EOL> ) <EOL> self . assertEqual ( self . input_list , output ) <EOL> output = api_utils . simple_filter ( <EOL> copy . deepcopy ( self . input_list ) , <EOL> attr = '<STR_LIT:status>' , <EOL> property_field = '<STR_LIT>' , <EOL> ) <EOL> self . assertEqual ( self . input_list , output ) <EOL> def test_simple_filter_prop_attr_value ( self ) : <EOL> output = api_utils . simple_filter ( <EOL> copy . deepcopy ( self . input_list ) , <EOL> attr = '<STR_LIT:b>' , <EOL> value = <NUM_LIT:2> , <EOL> property_field = '<STR_LIT>' , <EOL> ) <EOL> self . assertEqual ( <EOL> [ api_fakes . RESP_ITEM_1 , api_fakes . RESP_ITEM_2 ] , <EOL> output , <EOL> ) <EOL> output = api_utils . simple_filter ( <EOL> copy . deepcopy ( self . input_list ) , <EOL> attr = '<STR_LIT:b>' , <EOL> value = <NUM_LIT:9> , <EOL> property_field = '<STR_LIT>' , <EOL> ) <EOL> self . assertEqual ( [ ] , output ) </s>
