Exemple #1
0
 def post(self, request, flightplan_id):
     flightplan = get_object_or_404(FlightPlan, pk=flightplan_id)
     serializer = FlightPlanSerializer(flightplan, data=request.data)
     if not serializer.is_valid():            
         return Response({'serializer': serializer, 'flightplan': flightplan, 'style': self.style})
     serializer.save()
     return redirect('flightplans-list')
Exemple #2
0
    def test_gcs_operations_flight_plan_data_serializer(self):
        data = self._get_data_for_model('FlightPlan')
        # plan_file_json and geo_json are JSONFields
        data['plan_file_json'] = json.loads(data['plan_file_json'])
        data['geo_json'] = json.loads(data['geo_json'])
        flight_plan_serializer = FlightPlanSerializer(data=data)
        required_keys = {'name', 'plan_file_json'}

        self.assertTrue(flight_plan_serializer.is_valid())
        self.assertEqual(set(flight_plan_serializer.validated_data.keys()), required_keys)
        self.assertEqual(flight_plan_serializer.errors, dict())
Exemple #3
0
 def get(self, request, flightoperation_id):
     flightoperation = get_object_or_404(FlightOperation,
                                         pk=flightoperation_id)
     serializer = FlightPlanSerializer(flightoperation)
     return Response({
         'serializer': serializer,
         'flightoperation': flightoperation
     })
 def test_gcs_operations_flight_plan_instance_serializer(self):
     flight_plan_serializer = FlightPlanSerializer(
         instance=FlightPlan.objects.first())
     required_keys = {
         'id', 'updated_at', 'name', 'plan_file_json', 'created_at'
     }
     self.assertEqual(set(flight_plan_serializer.data.keys()),
                      required_keys)
Exemple #5
0
 def get(self, request, flightplan_id):
     flightplan = get_object_or_404(FlightPlan, pk=flightplan_id)
     serializer = FlightPlanSerializer(flightplan)
     return Response({'serializer': serializer, 'flightplan': flightplan})
 def test_gcs_operations_flight_plan_serializer(self):
     data = self._get_data_for_model('FlightPlan')
     flight_plan_serializer = FlightPlanSerializer(data=data)
     self.assertTrue(flight_plan_serializer.is_valid())
     self.assertNotEqual(flight_plan_serializer.validated_data, dict)
     self.assertEqual(flight_plan_serializer.errors, dict())