Exemplo n.º 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')
Exemplo n.º 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())
 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())