Skip to content

Commit

Permalink
Rollback fixtures and clean up 🧼
Browse files Browse the repository at this point in the history
  • Loading branch information
Kezzsim committed Feb 5, 2024
1 parent b5101ed commit e3c9728
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
6 changes: 3 additions & 3 deletions suitcase/mongo_normalized/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,10 @@ def update(self, name, doc):
if field in old and field in doc:
if old[field] != doc[field]:
# Allow the removal of restricted fields, but not update
if doc[field] != None:
if doc[field] is not None:
raise ValueError(
f"Field '{field}' is restricted and cannot be changed."
)
f"Field '{field}' is restricted and cannot be changed."
)
target_uid_docs = revisions_col.find({"document.uid": doc["uid"]})
cur = target_uid_docs.sort([("revision", pymongo.DESCENDING)]).limit(1)
wrapped = dict()
Expand Down
7 changes: 3 additions & 4 deletions suitcase/mongo_normalized/tests/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# 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 @@ -11,12 +10,12 @@
def db_factory(request):
def inner():
database_name = f'test-{str(uuid.uuid4())}'
uri = 'mongodb://dbroker:secret@localhost:27017/test_database?authSource=admin'
client = pymongo.MongoClient(uri, False)
uri = 'mongodb://localhost:27017/'
client = mongomock.MongoClient(uri)

def drop():
client.drop_database(database_name)

request.addfinalizer(drop)
return client[database_name]
return inner
return inner

0 comments on commit e3c9728

Please sign in to comment.