def test_add_to_heap_map_empty(domain_code, page_title, count_views): test_heap_map = {'domain_code': []} add_to_heap_map( most_viewed_map=test_heap_map, domain_code=domain_code, page_title=page_title, count_views=count_views, top_n_pageviews=25) assert test_heap_map[domain_code] == [(count_views, page_title)]
def test_add_to_heap_defaultdict_empty(domain_code, page_title, count_views): test_heap_map = defaultdict(list) add_to_heap_map( most_viewed_map=test_heap_map, domain_code=domain_code, page_title=page_title, count_views=count_views, top_n_pageviews=25) assert test_heap_map[domain_code] == [(count_views, page_title)]
def test_heap_removes_smallest_element(domain_code, page_title, heap_map_size_3): my_count_views = 4 add_to_heap_map( most_viewed_map=heap_map_size_3, domain_code=domain_code, page_title=page_title, count_views=my_count_views, top_n_pageviews=3) assert (3, page_title) not in heap_map_size_3[domain_code]
def test_heap_adds_bigger_element(domain_code, page_title, heap_map_size_3): my_count_views = 4 add_to_heap_map( most_viewed_map=heap_map_size_3, domain_code=domain_code, page_title=page_title, count_views=my_count_views, top_n_pageviews=3) assert (my_count_views, page_title) in heap_map_size_3[domain_code]
def test_dont_add_to_heap_if_smallest_and_full(domain_code, page_title, heap_map_size_3): my_count_views = 2 add_to_heap_map( most_viewed_map=heap_map_size_3, domain_code=domain_code, page_title=page_title, count_views=my_count_views, top_n_pageviews=3) assert (my_count_views, page_title) not in heap_map_size_3[domain_code]
def test_add_to_heap_still_room_left(domain_code, page_title, heap_map_size_3): my_count_views = 2 add_to_heap_map( most_viewed_map=heap_map_size_3, domain_code=domain_code, page_title=page_title, count_views=my_count_views, top_n_pageviews=25) assert (2, page_title) in heap_map_size_3[domain_code]