diff --git a/suitcase/mongo_normalized/__init__.py b/suitcase/mongo_normalized/__init__.py index dcd2f8a..e7c1da8 100644 --- a/suitcase/mongo_normalized/__init__.py +++ b/suitcase/mongo_normalized/__init__.py @@ -208,7 +208,9 @@ def update(self, name, doc): for field in restricted_fields: if field in old and field in doc: if old[field] != doc[field]: - raise ValueError( + # Allow the removal of restricted fields, but not update + if doc[field] != None: + raise ValueError( f"Field '{field}' is restricted and cannot be changed." ) target_uid_docs = revisions_col.find({"document.uid": doc["uid"]}) @@ -224,7 +226,6 @@ def update(self, name, doc): else: raise NotImplementedError( f"Updating a {name} document is not currently supported. " - f"Only updates to 'start' documents are supported." ) def start(self, doc): diff --git a/suitcase/mongo_normalized/tests/fixtures.py b/suitcase/mongo_normalized/tests/fixtures.py index 2fca399..7c77189 100644 --- a/suitcase/mongo_normalized/tests/fixtures.py +++ b/suitcase/mongo_normalized/tests/fixtures.py @@ -2,6 +2,7 @@ # intake-bluesky-mongo) to import and reuse this fixtures without importing # *all* the fixtures used in conftest and the dependencies that they carry. import mongomock +import pymongo import pytest import uuid @@ -10,8 +11,8 @@ def db_factory(request): def inner(): database_name = f'test-{str(uuid.uuid4())}' - uri = 'mongodb://localhost:27017/' - client = mongomock.MongoClient(uri) + uri = 'mongodb://dbroker:secret@localhost:27017/test_database?authSource=admin' + client = pymongo.MongoClient(uri, False) def drop(): client.drop_database(database_name)