import tempfile from flask import url_for from tests.base import BaseTestCase from tests.client.file_tests import * from tests.client.label_tests import * from tests.client.project_tests import * from tests.client.result_tests import * class FolderInformationTest(BaseTestCase): def _check(self, url, folder, content_should): response = self.post(url, json=dict(folder=folder)) self.assertTrue(response.is_json) self.assertDictEqual(content_should, response.json) def test_folder_information(self): url = url_for("folder_information") self.post(url, json=dict(), status_code=400) with tempfile.TemporaryDirectory() as folder: self._check(url, "/not_existing/folder", dict(exists=False)) for i in range(10): self._check(url, folder, dict(exists=True, count=i)) f = tempfile.NamedTemporaryFile(dir=folder, delete=False)