Exemplo n.º 1
0
 def test_parser(self):
     # 97 Concorde
     #   all active
     # 89 777
     #   all inactive
     #   20 in maintenance
     self.planes_list = build_planes_from_html(self.html_page)
     self.assertEqual(len(self.planes_list), 186)
     planes_by_type = split_planes_list_by_type(self.planes_list)
     self.assertEqual(len(planes_by_type['supersonic_planes']), 97)
     self.assertEqual(len(planes_by_type['commercial_planes']), 89)
     self.assertEqual(len(planes_by_type['supersonic_ready_planes']), 0)
     self.assertEqual(len(planes_by_type['commercial_ready_planes']), 69)
Exemplo n.º 2
0
def planes_value(request):
    response = ''
    other_airports = get_other_airports_id()
    for j in other_airports:
        value_sum = 0
        planes_nb = 0
        switch_to_airport(j)
        current_airport = Airport()
        page = get_request(PLANES_PAGE)
        ready_planes = build_planes_from_html(page)
        for i in ready_planes:
            if i.get_value:
                if i.get_value():
                    value_sum += i.get_value()
                    planes_nb += 1
        response += '{}({}/{}) <br/><br/>'.format(current_airport.airport_name, planes_nb,
                                                  current_airport.planes_capacity, format_amount(value_sum))

    return HttpResponse(response)
Exemplo n.º 3
0
 def build_planes(self):
     html_page = get_request(PLANES_PAGE)
     planes_list = build_planes_from_html(html_page)
     sorted_planes = split_planes_list_by_type(planes_list)
     return sorted_planes