Example #1
0
    def test_update_missing_resource(self, mock_get_db_connection):
        """Raises an error when the resource was not provided"""
        r = Resource(resource='test')

        with pytest.raises(OperationOutcome, match='Resource data is required to \
update a resource'):
            r = r.update(None)
        assert mock_get_db_connection.return_value.update.call_count == 0
Example #2
0
    def test_update_without_id(self, mock_get_db_connection):
        """Calls the update method of the fhirbase client and creates the resource
        """
        test_id = {'id': 'id'}
        resource_data = {'my': 'resource'}
        update_data = {'test': 'two'}
        create_ret_data = {**update_data, **test_id}
        mock_get_db_connection.return_value.create.return_value = \
            create_ret_data
        r = Resource(resource=resource_data)

        r = r.update(update_data)
        mock_get_db_connection.return_value.create.assert_called_once_with({
            'resourceType': 'Resource',
            **update_data
        })
        assert r.resource == create_ret_data
        assert r.id == test_id['id']