<s> from graph_explorer import structured_metrics <EOL> import testhelpers <EOL> def test_parse_count_and_rate ( ) : <EOL> s_metrics = structured_metrics . StructuredMetrics ( ) <EOL> s_metrics . load_plugins ( ) <EOL> tags_base = { <EOL> '<STR_LIT>' : '<STR_LIT:foo>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:source>' : '<STR_LIT>' , <EOL> } <EOL> def get_proto2 ( key , target_type , unit , updates = { } ) : <EOL> return testhelpers . get_proto2 ( key , tags_base , target_type , unit , updates ) <EOL> key = "<STR_LIT>" <EOL> expected = get_proto2 ( key , '<STR_LIT>' , '<STR_LIT>' ) <EOL> real = s_metrics . list_metrics ( [ key ] ) <EOL> assert len ( real ) == <NUM_LIT:1> <EOL> assert expected == real . values ( ) [ <NUM_LIT:0> ] <EOL> key = "<STR_LIT>" <EOL> expected = get_proto2 ( key , '<STR_LIT:count>' , '<STR_LIT>' ) <EOL> real = s_metrics . list_metrics ( [ key ] ) <EOL> assert len ( real ) == <NUM_LIT:1> <EOL> assert expected == real . values ( ) [ <NUM_LIT:0> ] <EOL> def test_parse_timers ( ) : <EOL> s_metrics = structured_metrics . StructuredMetrics ( ) <EOL> s_metrics . load_plugins ( ) <EOL> tags_base = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:source>' : '<STR_LIT>' , <EOL> } <EOL> def get_proto2 ( key , target_type , unit , updates = { } ) : <EOL> return testhelpers . get_proto2 ( key , tags_base , target_type , unit , updates ) <EOL> key = "<STR_LIT>" <EOL> expected = get_proto2 ( key , '<STR_LIT:count>' , '<STR_LIT>' ) <EOL> real = s_metrics . list_metrics ( [ key ] ) <EOL> assert len ( real ) == <NUM_LIT:1> <EOL> assert expected == real . values ( ) [ <NUM_LIT:0> ] <EOL> key = "<STR_LIT>" <EOL> expected = get_proto2 ( key , '<STR_LIT>' , '<STR_LIT>' ) <EOL> real = s_metrics . list_metrics ( [ key ] ) <EOL> assert len ( real ) == <NUM_LIT:1> <EOL> assert expected == real . values ( ) [ <NUM_LIT:0> ] <EOL> key = "<STR_LIT>" <EOL> expected = get_proto2 ( key , '<STR_LIT>' , '<STR_LIT>' , { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> real = s_metrics . list_metrics ( [ key ] ) <EOL> assert len ( real ) == <NUM_LIT:1> <EOL> assert expected == real . values ( ) [ <NUM_LIT:0> ] <EOL> key = "<STR_LIT>" <EOL> expected = get_proto2 ( key , '<STR_LIT>' , '<STR_LIT>' , { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> real = s_metrics . list_metrics ( [ key ] ) <EOL> assert len ( real ) == <NUM_LIT:1> <EOL> assert expected == real . values ( ) [ <NUM_LIT:0> ] <EOL> key = "<STR_LIT>" <EOL> expected = get_proto2 ( key , '<STR_LIT>' , '<STR_LIT>' , { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> real = s_metrics . list_metrics ( [ key ] ) <EOL> assert len ( real ) == <NUM_LIT:1> <EOL> assert expected == real . values ( ) [ <NUM_LIT:0> ] <EOL> key = "<STR_LIT>" <EOL> expected = get_proto2 ( key , '<STR_LIT>' , '<STR_LIT>' , { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> real = s_metrics . list_metrics ( [ key ] ) <EOL> assert len ( real ) == <NUM_LIT:1> <EOL> assert expected == real . values ( ) [ <NUM_LIT:0> ] <EOL> key = "<STR_LIT>" <EOL> expected = get_proto2 ( key , '<STR_LIT>' , '<STR_LIT>' , { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> real = s_metrics . list_metrics ( [ key ] ) <EOL> assert len ( real ) == <NUM_LIT:1> <EOL> assert expected == real . values ( ) [ <NUM_LIT:0> ] <EOL> key = "<STR_LIT>" <EOL> expected = get_proto2 ( key , '<STR_LIT>' , '<STR_LIT>' , { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> real = s_metrics . list_metrics ( [ key ] ) <EOL> assert len ( real ) == <NUM_LIT:1> <EOL> assert expected == real . values ( ) [ <NUM_LIT:0> ] <EOL> key = "<STR_LIT>" <EOL> expected = get_proto2 ( key , '<STR_LIT>' , '<STR_LIT>' , { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> real = s_metrics . list_metrics ( [ key ] ) <EOL> assert len ( real ) == <NUM_LIT:1> <EOL> assert expected == real . values ( ) [ <NUM_LIT:0> ] <EOL> key = "<STR_LIT>" <EOL> expected = get_proto2 ( key , '<STR_LIT>' , '<STR_LIT>' , { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> real = s_metrics . list_metrics ( [ key ] ) <EOL> assert len ( real ) == <NUM_LIT:1> <EOL> assert expected == real . values ( ) [ <NUM_LIT:0> ] <EOL> key = "<STR_LIT>" <EOL> expected = get_proto2 ( key , '<STR_LIT>' , '<STR_LIT>' , { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> real = s_metrics . list_metrics ( [ key ] ) <EOL> assert len ( real ) == <NUM_LIT:1> <EOL> assert expected == real . values ( ) [ <NUM_LIT:0> ] <EOL> key = "<STR_LIT>" <EOL> expected = get_proto2 ( key , '<STR_LIT>' , '<STR_LIT>' , { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' } ) <EOL> real = s_metrics . list_metrics ( [ key ] ) <EOL> assert len ( real ) == <NUM_LIT:1> <EOL> assert expected == real . values ( ) [ <NUM_LIT:0> ] <EOL> key = "<STR_LIT>" <EOL> expected = get_proto2 ( key , '<STR_LIT>' , '<STR_LIT>' , { '<STR_LIT>' : '<STR_LIT:5>' , '<STR_LIT>' : '<STR_LIT>' } ) <EOL> real = s_metrics . list_metrics ( [ key ] ) <EOL> assert len ( real ) == <NUM_LIT:1> <EOL> assert expected == real . values ( ) [ <NUM_LIT:0> ] <EOL> key = "<STR_LIT>" <EOL> expected = get_proto2 ( key , '<STR_LIT>' , '<STR_LIT>' , { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' } ) <EOL> real = s_metrics . list_metrics ( [ key ] ) <EOL> assert len ( real ) == <NUM_LIT:1> <EOL> assert expected == real . values ( ) [ <NUM_LIT:0> ] </s>
