-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updated
force_revision_creation_for
sample
- Loading branch information
Showing
1 changed file
with
18 additions
and
15 deletions.
There are no files selected for viewing
33 changes: 18 additions & 15 deletions
33
Documentation/5.4/Samples/python/DocumentExtensions/Revisions/Revisions.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |