示例#1
0
    def test_update_with_id(self, mock_get_store):
        """Test update with id.

        Calls the update method of the fhirstore client
        and registers the resource
        """
        resource = Patient(id="test")
        mock_get_store.return_value.normalize_resource.return_value = resource
        mock_get_store.return_value.update.return_value = Patient(
            id="test", gender="other")

        update_data = {"gender": "other"}
        r = BaseResource(id="test", resource=resource)
        r.update(update_data)

        mock_get_store.return_value.update.assert_called_once_with(
            "test", update_data)
        assert r.resource == Patient(id="test", gender="other")
示例#2
0
    def test_update_missing_resource(self, mock_get_store):
        """Raises an error when the resource was not provided"""
        r = BaseResource(id="1")

        with pytest.raises(
                BadRequest,
                match="Resource data is required to update a resource",
        ):
            r = r.update(None)
        assert mock_get_store.return_value.update.call_count == 0
示例#3
0
    def test_update_id_dont_match(self, mock_get_store):
        """Raises an error when the resource was not provided"""
        r = BaseResource(id="1")

        with pytest.raises(
                BadRequest,
                match="Resource id and update payload do not match",
        ):
            r = r.update({"id": "2"})
        assert mock_get_store.return_value.update.call_count == 0