Skip to content

Instantly share code, notes, and snippets.

@elliotchance
Created December 4, 2019 22:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elliotchance/058f750fcc479dcbc40d1cd71c902596 to your computer and use it in GitHub Desktop.
Save elliotchance/058f750fcc479dcbc40d1cd71c902596 to your computer and use it in GitHub Desktop.
class DirtyRead(TransactionTest):
def run(self):
result1 = self.client1.fetch_record(id=1)
self.client2.update_record(id=1, name="Joe 2")
result2 = self.client1.fetch_record(id=1)
return result1 != result2
class NonRepeatableRead(TransactionTest):
def run(self):
result1 = self.client1.fetch_record(id=1)
self.client2.update_record(id=1, name="Joe 2")
self.client2.commit()
result2 = self.client1.fetch_record(id=1)
return result1 != result2
class PhantomRead(TransactionTest):
def run(self):
result1 = len(self.client1.fetch(lambda r: 1 <= r['id'] <= 3))
self.client2.add_record(id=2, name="John")
self.client2.commit()
result2 = self.client1.count_records(min_id=1, max_id=3)
return result1 != result2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment