Ejemplo n.º 1
0
 def test_create_missing_resource(self, mock_get_store):
     """Raises an error when the resource data was not provided at init"""
     r = BaseResource(id="id")
     with pytest.raises(BadRequest,
                        match="Missing resource data to create a resource"):
         r.create()
     assert mock_get_store.return_value.create.call_count == 0
Ejemplo n.º 2
0
    def test_create_extra_id(self, mock_get_store):
        """Accepts the resource data when an id was provided"""
        resource = Patient(id="test")
        mock_get_store.return_value.normalize_resource.return_value = resource
        mock_get_store.return_value.create.return_value = resource
        mock_get_store.return_value.read.return_value = None

        r = BaseResource(resource=resource)

        r.create()
        assert r.id == "test"
        assert r.resource == resource
Ejemplo n.º 3
0
    def test_create(self, mock_uuid, mock_get_store):
        """Test create method.

        Calls the create method of the fhirstore client
        and registers the ID
        """
        resource = Patient(gender="male")
        mock_get_store.return_value.normalize_resource.return_value = resource

        mock_get_store.return_value.create.return_value = resource
        mock_get_store.return_value.read.return_value = None
        r = BaseResource(resource=resource)

        r.create()
        mock_get_store.return_value.create.assert_called_once_with(resource)
        assert r.id == "uuid"
        assert r.resource == resource