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)
Esempio n. 2
0
 def test_can_instantiate_serializer__with_no_properties(self):
     data = {
         'properties': None,
         'id': 1,
         'name': 'Test1',
     }
     serializer = WorkBatchDetailsSerializer(data=data)
     assert serializer.is_valid(), serializer.errors
Esempio n. 3
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
Esempio n. 4
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'
Esempio n. 5
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'
Esempio n. 6
0
 def test_can_serialize_workbatch_details(self):
     workbatch = MyWorkbatchImplementation(name="Test1")
     workbatch.kit_type = 'kit type value'
     workbatch.save()
     result = WorkBatchDetailsSerializer(workbatch).data
     assert result.get('id') == workbatch.id
     assert result.get('name') == 'Test1'
     properties = result.get('properties')
     assert properties['kit_type']['value'] == 'kit type value'
     assert result.get('created_at', None)
     assert result.get('updated_at', None)
    def get(self, request, organization_slug, work_batch_id):
        workbatch = self.app.workbatches.get(id=work_batch_id)

        return Response(WorkBatchDetailsSerializer(workbatch).data, status=200)