Exemplo n.º 1
0
 def test_exclude_fully_selesai(self):
     """If all AircraftTypes for a Pilot/Airstrip pair have a Sudah Selesai
     status, that Pilot/Airstrip pair should be removed from the results."""
     c = helper.create_checkout()
     
     self.expected['aircraft_types'] = util.get_aircrafttype_names()
     
     self.assertEqual(util.belum_selesai(), self.expected)
Exemplo n.º 2
0
 def test_exclude_fully_selesai(self):
     """If all AircraftTypes for a Pilot/Airstrip pair have a Sudah Selesai
     status, that Pilot/Airstrip pair should be removed from the results."""
     c = helper.create_checkout()
     
     self.expected['aircraft_types'] = util.get_aircrafttype_names()
     
     self.assertEqual(util.belum_selesai(), self.expected)
Exemplo n.º 3
0
    def post(self, request, *args, **kwargs):
        """If the filter is valid, renders the filtered checkout data"""
        logger.debug("=> FilterFormView.post")
        logger.debug(request.POST)
        form = self.form_class(request.POST)
        context = {'form': form}

        if not form.is_valid():
            logger.debug("Unable to validate form data")
        else:
            logger.debug(form.cleaned_data)
            status = form.cleaned_data['checkout_status']
            if status == util.CHECKOUT_SUDAH:
                context['checkouts'] = util.sudah_selesai(**form.cleaned_data)
            else:
                context['checkouts'] = util.belum_selesai(**form.cleaned_data)

            context['show_summary'] = True

        return self.render_to_response(context)
Exemplo n.º 4
0
 def test_with_data(self):
     pilot1 = helper.create_pilot('kim', 'Kim', 'Pilot1')
     pilot2 = helper.create_pilot('sam', 'Sam', 'Pilot2')
     actype1 = helper.create_aircrafttype('Name1')
     actype2 = helper.create_aircrafttype('Name2')
     airstrip1 = helper.create_airstrip('ID1', 'Airstrip1')
     airstrip2 = helper.create_airstrip('ID2', 'Airstrip2')
     airstrip3 = helper.create_airstrip('ID3', 'Airstrip3')
     
     c1 = helper.create_checkout(pilot=pilot1, airstrip=airstrip1, aircraft_type=actype1)
     c2 = helper.create_checkout(pilot=pilot1, airstrip=airstrip1, aircraft_type=actype2)
     c3 = helper.create_checkout(pilot=pilot2, airstrip=airstrip2, aircraft_type=actype1)
     
     results = [{
         'pilot_name': pilot1.full_name,
         'pilot_slug': pilot1.username,
         'airstrip_ident': airstrip2.ident,
         'airstrip_name': airstrip2.name,
         'actypes': {
             actype1.name: util.CHECKOUT_BELUM,
             actype2.name: util.CHECKOUT_UNPRECEDENTED,
         },
     }, {
         'pilot_name': pilot2.full_name,
         'pilot_slug': pilot2.username,
         'airstrip_ident': airstrip1.ident,
         'airstrip_name': airstrip1.name,
         'actypes': {
             actype1.name: util.CHECKOUT_BELUM,
             actype2.name: util.CHECKOUT_BELUM,
         },
     }, {
         'pilot_name': pilot2.full_name,
         'pilot_slug': pilot2.username,
         'airstrip_ident': airstrip2.ident,
         'airstrip_name': airstrip2.name,
         'actypes': {
             actype1.name: util.CHECKOUT_SUDAH,
             actype2.name: util.CHECKOUT_UNPRECEDENTED,
         },
     },]
     
     self.expected['aircraft_types'] = util.get_aircrafttype_names()
     self.expected['results'] = results
     
     self.assertEqual(util.belum_selesai(), self.expected)
     
     # Since we already have all these objects created, let's test the
     # 'belum selesai' filtering feature!
     self.expected['results'] = results[:1]
     self.assertEqual(util.belum_selesai(pilot=pilot1), self.expected)
     self.expected['results'] = results[1:]
     self.assertEqual(util.belum_selesai(pilot=pilot2), self.expected)
     self.expected['results'] = [results[1],]
     self.assertEqual(util.belum_selesai(airstrip=airstrip1), self.expected)
     self.expected['results'] = [r for i, r in enumerate(results) if i in (0,2)]
     self.assertEqual(util.belum_selesai(airstrip=airstrip2), self.expected)
     
     self.expected['results'] = results[:2]
     for r in self.expected['results']:
         r['actypes'].pop(actype2.name)
     self.expected['aircraft_types'] = [actype1.name,]
     self.assertEqual(util.belum_selesai(aircraft_type=actype1), self.expected)
Exemplo n.º 5
0
 def test_empty(self):
     self.assertEqual(util.belum_selesai(), self.expected)
Exemplo n.º 6
0
 def test_with_data(self):
     pilot1 = helper.create_pilot('kim', 'Kim', 'Pilot1')
     pilot2 = helper.create_pilot('sam', 'Sam', 'Pilot2')
     actype1 = helper.create_aircrafttype('Name1')
     actype2 = helper.create_aircrafttype('Name2')
     airstrip1 = helper.create_airstrip('ID1', 'Airstrip1')
     airstrip2 = helper.create_airstrip('ID2', 'Airstrip2')
     airstrip3 = helper.create_airstrip('ID3', 'Airstrip3')
     
     c1 = helper.create_checkout(pilot=pilot1, airstrip=airstrip1, aircraft_type=actype1)
     c2 = helper.create_checkout(pilot=pilot1, airstrip=airstrip1, aircraft_type=actype2)
     c3 = helper.create_checkout(pilot=pilot2, airstrip=airstrip2, aircraft_type=actype1)
     
     results = [{
         'pilot_name': pilot1.full_name,
         'pilot_slug': pilot1.username,
         'airstrip_ident': airstrip2.ident,
         'airstrip_name': airstrip2.name,
         'actypes': {
             actype1.name: util.CHECKOUT_BELUM,
             actype2.name: util.CHECKOUT_UNPRECEDENTED,
         },
     }, {
         'pilot_name': pilot2.full_name,
         'pilot_slug': pilot2.username,
         'airstrip_ident': airstrip1.ident,
         'airstrip_name': airstrip1.name,
         'actypes': {
             actype1.name: util.CHECKOUT_BELUM,
             actype2.name: util.CHECKOUT_BELUM,
         },
     }, {
         'pilot_name': pilot2.full_name,
         'pilot_slug': pilot2.username,
         'airstrip_ident': airstrip2.ident,
         'airstrip_name': airstrip2.name,
         'actypes': {
             actype1.name: util.CHECKOUT_SUDAH,
             actype2.name: util.CHECKOUT_UNPRECEDENTED,
         },
     },]
     
     self.expected['aircraft_types'] = util.get_aircrafttype_names()
     self.expected['results'] = results
     
     self.assertEqual(util.belum_selesai(), self.expected)
     
     # Since we already have all these objects created, let's test the
     # 'belum selesai' filtering feature!
     self.expected['results'] = results[:1]
     self.assertEqual(util.belum_selesai(pilot=pilot1), self.expected)
     self.expected['results'] = results[1:]
     self.assertEqual(util.belum_selesai(pilot=pilot2), self.expected)
     self.expected['results'] = [results[1],]
     self.assertEqual(util.belum_selesai(airstrip=airstrip1), self.expected)
     self.expected['results'] = [r for i, r in enumerate(results) if i in (0,2)]
     self.assertEqual(util.belum_selesai(airstrip=airstrip2), self.expected)
     
     self.expected['results'] = results[:2]
     for r in self.expected['results']:
         r['actypes'].pop(actype2.name)
     self.expected['aircraft_types'] = [actype1.name,]
     self.assertEqual(util.belum_selesai(aircraft_type=actype1), self.expected)
Exemplo n.º 7
0
 def test_empty(self):
     self.assertEqual(util.belum_selesai(), self.expected)