Ejemplo n.º 1
0
    def test_with_existing_locked_upload_area__raises(self):
        db_area = self.create_upload_area()
        area = UploadArea(db_area.uuid)
        area.lock()

        with self.assertRaises(UploadException):
            area.credentials()
Ejemplo n.º 2
0
class TestUploadAreaLocking(UploadAreaTest):
    def setUp(self):
        super().setUp()
        self.db_area = self.create_upload_area(db_session=self.db)
        self.area = UploadArea(uuid=self.db_area.uuid)

    def test_lock__with_unlocked_area__locks_area(self):
        self.assertEqual("UNLOCKED", self.db_area.status)

        self.area.lock()

        self.db.refresh(self.db_area)
        self.assertEqual("LOCKED", self.db_area.status)

    def test_unlock__with_locked_area__unlocks_area(self):
        self.db_area.status = 'LOCKED'
        self.db.add(self.db_area)
        self.db.commit()

        self.area.unlock()

        self.db.refresh(self.db_area)
        self.assertEqual("UNLOCKED", self.db_area.status)