Skip to content

Commit

Permalink
Permit removing the start_id but not in validator (yet)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kezzsim committed Feb 5, 2024
1 parent defb806 commit b5101ed
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions suitcase/mongo_normalized/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]})
Expand All @@ -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):
Expand Down
5 changes: 3 additions & 2 deletions suitcase/mongo_normalized/tests/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)
Expand Down

0 comments on commit b5101ed

Please sign in to comment.