<s> import datetime <EOL> import mock <EOL> import testtools <EOL> from openstack . telemetry . v2 import statistics <EOL> EXAMPLE = { <EOL> '<STR_LIT>' : '<STR_LIT:1>' , <EOL> '<STR_LIT>' : '<STR_LIT:2>' , <EOL> '<STR_LIT:count>' : '<STR_LIT:3>' , <EOL> '<STR_LIT>' : '<STR_LIT:4>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> class TestStatistics ( testtools . TestCase ) : <EOL> def test_basic ( self ) : <EOL> sot = statistics . Statistics ( ) <EOL> self . assertEqual ( '<STR_LIT>' , sot . resource_key ) <EOL> self . assertIsNone ( sot . resources_key ) <EOL> self . assertEqual ( '<STR_LIT>' , sot . base_path ) <EOL> self . assertEqual ( '<STR_LIT>' , sot . service . service_type ) <EOL> self . assertFalse ( sot . allow_create ) <EOL> self . assertFalse ( sot . allow_retrieve ) <EOL> self . assertFalse ( sot . allow_update ) <EOL> self . assertFalse ( sot . allow_delete ) <EOL> self . assertTrue ( sot . allow_list ) <EOL> def test_make_it ( self ) : <EOL> sot = statistics . Statistics ( EXAMPLE ) <EOL> self . assertIsNone ( sot . id ) <EOL> self . assertEqual ( EXAMPLE [ '<STR_LIT>' ] , sot . aggregate ) <EOL> self . assertEqual ( EXAMPLE [ '<STR_LIT>' ] , sot . avg ) <EOL> self . assertEqual ( EXAMPLE [ '<STR_LIT:count>' ] , sot . count ) <EOL> self . assertEqual ( EXAMPLE [ '<STR_LIT>' ] , sot . duration ) <EOL> dt = datetime . datetime ( <NUM_LIT> , <NUM_LIT:3> , <NUM_LIT:9> , <NUM_LIT:12> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) . replace ( <EOL> tzinfo = None ) <EOL> self . assertEqual ( dt , sot . duration_end_at . replace ( tzinfo = None ) ) <EOL> dt = datetime . datetime ( <NUM_LIT> , <NUM_LIT:3> , <NUM_LIT:9> , <NUM_LIT:12> , <NUM_LIT:15> , <NUM_LIT> , <NUM_LIT> ) . replace ( <EOL> tzinfo = None ) <EOL> self . assertEqual ( dt , sot . duration_start_at . replace ( tzinfo = None ) ) <EOL> self . assertEqual ( EXAMPLE [ '<STR_LIT>' ] , sot . group_by ) <EOL> self . assertEqual ( EXAMPLE [ '<STR_LIT>' ] , sot . max ) <EOL> self . assertEqual ( EXAMPLE [ '<STR_LIT>' ] , sot . min ) <EOL> self . assertEqual ( EXAMPLE [ '<STR_LIT>' ] , sot . period ) <EOL> dt = datetime . datetime ( <NUM_LIT> , <NUM_LIT:3> , <NUM_LIT:9> , <NUM_LIT:12> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) . replace ( <EOL> tzinfo = None ) <EOL> self . assertEqual ( dt , sot . period_end_at . replace ( tzinfo = None ) ) <EOL> dt = datetime . datetime ( <NUM_LIT> , <NUM_LIT:3> , <NUM_LIT:9> , <NUM_LIT:12> , <NUM_LIT:15> , <NUM_LIT> , <NUM_LIT> ) . replace ( <EOL> tzinfo = None ) <EOL> self . assertEqual ( dt , sot . period_start_at . replace ( tzinfo = None ) ) <EOL> self . assertEqual ( EXAMPLE [ '<STR_LIT>' ] , sot . sum ) <EOL> self . assertEqual ( EXAMPLE [ '<STR_LIT>' ] , sot . unit ) <EOL> def test_list ( self ) : <EOL> sess = mock . Mock ( ) <EOL> resp = mock . Mock ( ) <EOL> resp . json = mock . Mock ( return_value = [ EXAMPLE ] ) <EOL> sess . get = mock . Mock ( return_value = resp ) <EOL> args = { '<STR_LIT>' : '<STR_LIT>' } <EOL> reply = statistics . Statistics . list ( sess , path_args = args ) <EOL> url = '<STR_LIT>' <EOL> stat = next ( reply ) <EOL> sess . get . assert_called_with ( url , endpoint_filter = stat . service , <EOL> params = { } ) <EOL> self . assertEqual ( EXAMPLE , stat ) <EOL> self . assertRaises ( StopIteration , next , reply ) </s>
