# Copyright (c) 2015, InfluxFramework LLC
# License: MIT. See LICENSE
import influxframework
from influxframework.tests.utils import InfluxFrameworkTestCase


class TestDocumentLocks(InfluxFrameworkTestCase):
	def test_locking(self):
		todo = influxframework.get_doc(dict(doctype="ToDo", description="test")).insert()
		todo_1 = influxframework.get_doc("ToDo", todo.name)

		todo.lock()
		self.assertRaises(influxframework.DocumentLockedError, todo_1.lock)
		todo.unlock()

		todo_1.lock()
		self.assertRaises(influxframework.DocumentLockedError, todo.lock)
		todo_1.unlock()
