コード例 #1
0
 def put(self, request, organization_slug, work_batch_id):
     workbatch = self.app.workbatches.get(id=work_batch_id)
     serializer = WorkBatchDetailsSerializer(workbatch, data=request.data)
     if not serializer.is_valid():
         return self.respond(serializer.errors, status=400)
     serializer.save()
     return Response({}, status=status.HTTP_200_OK)
コード例 #2
0
 def test_can_update_workbatch_properties__with_properties_set_to_empty(self):
     data = {
         'id': 1,
         'name': 'Test1',
         'properties': {}
     }
     workbatch = MyWorkbatchImplementation(name='my_workbatch')
     workbatch.save()
     serializer = WorkBatchDetailsSerializer(workbatch, data=data)
     assert serializer.is_valid()
     updated_workbatch = serializer.save()
     assert updated_workbatch.kit_type is None
コード例 #3
0
 def test_update_workbatch_properties__with_empty_dict__previous_values_dont_change(self):
     # TODO: is this the intended behavour?
     data = {
         'id': 1,
         'name': 'Test1',
         'properties': {}
     }
     workbatch = MyWorkbatchImplementation(name='my_workbatch')
     workbatch.kit_type = 'kit type value'
     workbatch.save()
     serializer = WorkBatchDetailsSerializer(workbatch, data=data)
     assert serializer.is_valid()
     updated_workbatch = serializer.save()
     assert updated_workbatch.kit_type == 'kit type value'
コード例 #4
0
 def test_can_update_workbatch_property__from_no_value(self):
     data = {
         'id': 1,
         'name': 'Test1',
         'properties': {
             'kit_type': {'value': 'kit type value'},
         }
     }
     workbatch = MyWorkbatchImplementation(name='my_workbatch')
     workbatch.save()
     serializer = WorkBatchDetailsSerializer(workbatch, data=data)
     assert serializer.is_valid()
     updated_workbatch = serializer.save()
     assert updated_workbatch.kit_type == 'kit type value'