<s> from tempest . lib . common . utils import data_utils <EOL> from tempest import test <EOL> from neutron . tests . tempest . api import base <EOL> class MeteringTestJSON ( base . BaseAdminNetworkTest ) : <EOL> """<STR_LIT>""" <EOL> @ classmethod <EOL> @ test . requires_ext ( extension = "<STR_LIT>" , service = "<STR_LIT>" ) <EOL> def resource_setup ( cls ) : <EOL> super ( MeteringTestJSON , cls ) . resource_setup ( ) <EOL> description = "<STR_LIT>" <EOL> name = data_utils . rand_name ( "<STR_LIT>" ) <EOL> cls . metering_label = cls . create_metering_label ( name , description ) <EOL> remote_ip_prefix = ( "<STR_LIT>" if cls . _ip_version == <NUM_LIT:4> <EOL> else "<STR_LIT>" ) <EOL> direction = "<STR_LIT>" <EOL> cls . metering_label_rule = cls . create_metering_label_rule ( <EOL> remote_ip_prefix , direction , <EOL> metering_label_id = cls . metering_label [ '<STR_LIT:id>' ] ) <EOL> def _delete_metering_label ( self , metering_label_id ) : <EOL> self . admin_client . delete_metering_label ( metering_label_id ) <EOL> labels = self . admin_client . list_metering_labels ( id = metering_label_id ) <EOL> self . assertEqual ( len ( labels [ '<STR_LIT>' ] ) , <NUM_LIT:0> ) <EOL> def _delete_metering_label_rule ( self , metering_label_rule_id ) : <EOL> self . admin_client . delete_metering_label_rule ( <EOL> metering_label_rule_id ) <EOL> rules = ( self . admin_client . list_metering_label_rules ( <EOL> id = metering_label_rule_id ) ) <EOL> self . assertEqual ( len ( rules [ '<STR_LIT>' ] ) , <NUM_LIT:0> ) <EOL> @ test . idempotent_id ( '<STR_LIT>' ) <EOL> def test_list_metering_labels ( self ) : <EOL> body = self . admin_client . list_metering_labels ( id = <NUM_LIT> ) <EOL> metering_labels = body [ '<STR_LIT>' ] <EOL> self . assertEqual ( <NUM_LIT:0> , len ( metering_labels ) ) <EOL> @ test . idempotent_id ( '<STR_LIT>' ) <EOL> def test_create_delete_metering_label_with_filters ( self ) : <EOL> name = data_utils . rand_name ( '<STR_LIT>' ) <EOL> description = "<STR_LIT>" <EOL> body = self . admin_client . create_metering_label ( name = name , <EOL> description = description ) <EOL> metering_label = body [ '<STR_LIT>' ] <EOL> self . addCleanup ( self . _delete_metering_label , <EOL> metering_label [ '<STR_LIT:id>' ] ) <EOL> labels = ( self . admin_client . list_metering_labels ( <EOL> id = metering_label [ '<STR_LIT:id>' ] ) ) <EOL> self . assertEqual ( len ( labels [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> @ test . idempotent_id ( '<STR_LIT>' ) <EOL> def test_show_metering_label ( self ) : <EOL> body = self . admin_client . show_metering_label ( self . metering_label [ '<STR_LIT:id>' ] ) <EOL> metering_label = body [ '<STR_LIT>' ] <EOL> self . assertEqual ( self . metering_label [ '<STR_LIT:id>' ] , metering_label [ '<STR_LIT:id>' ] ) <EOL> self . assertEqual ( self . metering_label [ '<STR_LIT>' ] , <EOL> metering_label [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( self . metering_label [ '<STR_LIT:name>' ] , metering_label [ '<STR_LIT:name>' ] ) <EOL> self . assertEqual ( self . metering_label [ '<STR_LIT:description>' ] , <EOL> metering_label [ '<STR_LIT:description>' ] ) <EOL> @ test . idempotent_id ( '<STR_LIT>' ) <EOL> def test_list_metering_label_rules ( self ) : <EOL> body = self . admin_client . list_metering_label_rules ( id = <NUM_LIT> ) <EOL> metering_label_rules = body [ '<STR_LIT>' ] <EOL> self . assertEqual ( <NUM_LIT:0> , len ( metering_label_rules ) ) <EOL> @ test . idempotent_id ( '<STR_LIT>' ) <EOL> def test_create_delete_metering_label_rule_with_filters ( self ) : <EOL> remote_ip_prefix = ( "<STR_LIT>" if self . _ip_version == <NUM_LIT:4> <EOL> else "<STR_LIT>" ) <EOL> body = ( self . admin_client . create_metering_label_rule ( <EOL> remote_ip_prefix = remote_ip_prefix , <EOL> direction = "<STR_LIT>" , <EOL> metering_label_id = self . metering_label [ '<STR_LIT:id>' ] ) ) <EOL> metering_label_rule = body [ '<STR_LIT>' ] <EOL> self . addCleanup ( self . _delete_metering_label_rule , <EOL> metering_label_rule [ '<STR_LIT:id>' ] ) <EOL> rules = ( self . admin_client . list_metering_label_rules ( <EOL> id = metering_label_rule [ '<STR_LIT:id>' ] ) ) <EOL> self . assertEqual ( len ( rules [ '<STR_LIT>' ] ) , <NUM_LIT:1> ) <EOL> @ test . idempotent_id ( '<STR_LIT>' ) <EOL> def test_show_metering_label_rule ( self ) : <EOL> body = ( self . admin_client . show_metering_label_rule ( <EOL> self . metering_label_rule [ '<STR_LIT:id>' ] ) ) <EOL> metering_label_rule = body [ '<STR_LIT>' ] <EOL> self . assertEqual ( self . metering_label_rule [ '<STR_LIT:id>' ] , <EOL> metering_label_rule [ '<STR_LIT:id>' ] ) <EOL> self . assertEqual ( self . metering_label_rule [ '<STR_LIT>' ] , <EOL> metering_label_rule [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( self . metering_label_rule [ '<STR_LIT>' ] , <EOL> metering_label_rule [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( self . metering_label_rule [ '<STR_LIT>' ] , <EOL> metering_label_rule [ '<STR_LIT>' ] ) <EOL> self . assertFalse ( metering_label_rule [ '<STR_LIT>' ] ) <EOL> class MeteringIpV6TestJSON ( MeteringTestJSON ) : <EOL> _ip_version = <NUM_LIT:6> </s>
