Skip to content

Commit

Permalink
updated force_revision_creation_for sample
Browse files Browse the repository at this point in the history
  • Loading branch information
reebhub committed Jul 10, 2024
1 parent 377d5d2 commit 401b300
Showing 1 changed file with 18 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
from ravendb.primitives import constants

from examples_base import ExampleBase
from examples_base import ExampleBase, Company

class Force(ExampleBase):
def setUp(self):
super().setUp()

# region force_revision_creation_for
with self.store.open_session() as session:
company = session.load(company_id, Company)
company.name = "HR V2"
def test_force_revision_creation_for(self):
with self.embedded_server.get_document_store("ForceRevision") as store:
with store.open_session() as session:
self.add_companies(session)
company_id = "companies/1"
# region force_revision_creation_for
with store.open_session() as session:
company = session.load(company_id, Company)
company.name = "HR V2"

session.advanced.revisions.force_revision_creation_for(company)
session.save_changes()
session.advanced.revisions.force_revision_creation_for(company)
session.save_changes()

revisions = session.advanced.revisions.get_for(company.Id, Company)
revisions_count = len(revisions)
revisions = session.advanced.revisions.get_for(company.Id, Company)
revisions_count = len(revisions)

self.assertEqual(1, revisions_count)
# Assert revision contains the value 'Before' the changes...
self.assertEqual("HR", revisions[0].name)
# endregion
self.assertEqual(1, revisions_count)
# Assert revision contains the value 'Before' the changes...
self.assertEqual("HR V2", revisions[1].name)
# endregion

0 comments on commit 401b300

Please sign in to comment.