Exemplo n.º 1
0
 def get_sectors(self):
     barriers = self.get_barriers_list()
     data = list(barriers["all"])
     all_sectors_count = len(
         [b for b in data if b.sectors == AllSectors.name])
     choices = sectors.count_records("sectors",
                                     data,
                                     op="include",
                                     offset=all_sectors_count)
     return choices
Exemplo n.º 2
0
 def test_count_records__exact_match(self):
     """
     Used to help to display how many records each sector has at sectors
     filter.
     """
     dataset = dummy_barrier_list_results
     grouped_records = sectors.count_records("sectors", dataset)
     # it is grouped and ordered alphabetically
     aerospace = grouped_records["A"][1]
     assert "Aerospace" == aerospace.name
     # There are 2 records with aerospace listed in sectors
     assert 2 == len([b for b in dataset if aerospace.name in b.sectors])
     # However, there's only 1 record with ONLY aerospace listed in sectors
     assert 1 == aerospace.records_count
Exemplo n.º 3
0
 def test_count_records(self):
     """
     Used to help to display how many records each sector has at sectors
     filter.
     """
     dataset = dummy_barrier_list_results
     grouped_records = sectors.count_records("sectors",
                                             dataset,
                                             op="include")
     # it is grouped and ordered alphabetically
     aerospace = grouped_records["A"][1]
     assert "Aerospace" == aerospace.name
     assert 2 == aerospace.records_count
     assert 2 == len([b for b in dataset if aerospace.name in b.sectors])
Exemplo n.º 4
0
 def test_count_records__with_offset(self):
     """
     Used to help to display how many records each sector has at sectors
     filter.
     Offset is used to add an amount to the counted records.
     """
     offset = 2
     dataset = dummy_barrier_list_results
     grouped_records = sectors.count_records("sectors",
                                             dataset,
                                             op="include",
                                             offset=offset)
     # it is grouped and ordered alphabetically
     aerospace = grouped_records["A"][1]
     assert "Aerospace" == aerospace.name
     assert 2 == len([b for b in dataset if aerospace.name in b.sectors])
     assert 2 + offset == aerospace.records_count