def get_context_data(self, **kwargs): context = super(PilotDetail, self).get_context_data(**kwargs) context['checkouts'] = util.pilot_checkouts_grouped_by_airstrip( self.object) return context
def test_multiple_pilots(self): pilot1 = helper.create_pilot('kim', 'Kim', 'Pilot1') pilot2 = helper.create_pilot('sam', 'Sam', 'Pilot2') c1 = helper.create_checkout(pilot=pilot1) c2 = helper.create_checkout(pilot=pilot2, airstrip=c1.airstrip, aircraft_type=c1.aircraft_type) results = [{ 'pilot_name': pilot1.full_name, 'pilot_slug': pilot1.username, 'airstrip_ident': c1.airstrip.ident, 'airstrip_name': c1.airstrip.name, 'actypes': { c1.aircraft_type.name: util.CHECKOUT_SUDAH, }, },] self.expected['aircraft_types'] = [c1.aircraft_type.name,] self.expected['results'] = results self.assertEqual(util.pilot_checkouts_grouped_by_airstrip(pilot1), self.expected)
def test_empty(self): pilot = helper.create_pilot() self.assertEqual(util.pilot_checkouts_grouped_by_airstrip(pilot), self.expected)