def test_bottom_hierarchy_non_integer(): """ Hierachy values that are not integers should be ignored """ publisher_stats = PublisherStats() publisher_stats.aggregated = { 'by_hierarchy': { 'notaninteger': { 'testkey': 'v_notaninteger' }, } } assert publisher_stats.bottom_hierarchy() == {} publisher_stats.aggregated = { 'by_hierarchy': { 'notaninteger': { 'testkey': 'v_notaninteger' }, '2': { 'testkey': 'v2' }, '3': { 'testkey': 'v3' } } } assert publisher_stats.bottom_hierarchy() == {'testkey': 'v3'}
def test_bottom_hierarchy(): publisher_stats = PublisherStats() publisher_stats.aggregated = {'by_hierarchy': {}} assert publisher_stats.bottom_hierarchy() == {} publisher_stats.aggregated = { 'by_hierarchy': { '1': { 'testkey': 'v1' }, '2': { 'testkey': 'v2' }, '3': { 'testkey': 'v3' } } } assert publisher_stats.bottom_hierarchy() == {'testkey': 'v3'}