From d4712476684aab03be0ad026a2173740a8668e83 Mon Sep 17 00:00:00 2001 From: Evan Blaudy Date: Tue, 12 Nov 2024 16:10:43 +0100 Subject: [PATCH 1/4] [requirements] upgrade --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index f5229f3772..5405a0525a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -47,7 +47,7 @@ install_requires = flask==3.0.3 gazu==0.10.16 gevent-websocket==0.10.1 - gevent==24.10.3 + gevent==24.11.1 gunicorn==23.0.0 isoweek==1.3.3 itsdangerous==2.2.0 From f087d7e9cc0b9d7bd0bc5cf410e656102e34b16c Mon Sep 17 00:00:00 2001 From: Evan Blaudy Date: Wed, 13 Nov 2024 02:46:02 +0100 Subject: [PATCH 2/4] [ci] use latest ubuntu version for ci --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fa3406b5eb..79cbb2f478 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,7 +6,7 @@ on: [push, pull_request] jobs: ci: name: Test with different versions of Python 🐍 - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest env: INDEXER_KEY: testkey0123456789 PGPASSWORD: mysecretpassword From 9039328e8ad814ff344e95a3a54bc01cedff86ba Mon Sep 17 00:00:00 2001 From: Evan Blaudy Date: Wed, 13 Nov 2024 03:09:15 +0100 Subject: [PATCH 3/4] [ci] fix tests/shots/test_episodes.py::EpisodeTestCase::test_force_delete_episode --- tests/shots/test_episodes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/shots/test_episodes.py b/tests/shots/test_episodes.py index 742e69b62f..c9a8902198 100644 --- a/tests/shots/test_episodes.py +++ b/tests/shots/test_episodes.py @@ -128,7 +128,7 @@ def test_get_episodes_by_project_and_name(self): def test_force_delete_episode(self): self.get("data/episodes/%s" % self.episode_id) - self.delete("data/episodes/%s" % self.episode_id, 400) + self.delete("data/episodes/%s?force=true" % self.episode_id) self.get("data/episodes/%s" % self.episode_id, 404) def test_cant_delete_episode(self): From cdb71bc53592e4a8224a0f15bd9e93d45cebf37e Mon Sep 17 00:00:00 2001 From: Evan Blaudy Date: Wed, 13 Nov 2024 03:57:19 +0100 Subject: [PATCH 4/4] [ci] fix tests/chats/test_chat_routes.py::EventsRoutesTestCase::test_post_chat_message_with_attachment --- tests/base.py | 22 ++++++++++++++++------ tests/chats/test_chat_routes.py | 10 +++++++--- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/tests/base.py b/tests/base.py index c799bc2ad6..ed4892a092 100644 --- a/tests/base.py +++ b/tests/base.py @@ -62,6 +62,7 @@ class ApiTestCase(unittest.TestCase): """ Set of helpers to make test development easier. """ + @classmethod def setUpClass(cls): pass @@ -82,6 +83,7 @@ def setUp(self): app.app_context().push() from zou.app.utils import cache + cache.clear() def tearDown(self): @@ -233,11 +235,11 @@ def download_file(self, path, target_file_path, code=200): return open(target_file_path, "rb").read() - class ApiDBTestCase(ApiTestCase): """ Set of helpers for Api tests. """ + @classmethod def setUpClass(cls): """ @@ -246,6 +248,7 @@ def setUpClass(cls): """ super(ApiDBTestCase, cls).setUpClass() from zou.app.utils import dbhelpers + with app.app_context(): dbhelpers.drop_all() dbhelpers.create_all() @@ -258,10 +261,11 @@ def tearDownClass(cls): """ super(ApiDBTestCase, cls).tearDownClass() from zou.app.utils import dbhelpers + with app.app_context(): dbhelpers.drop_all() - - def setUp(self): + + def setUp(self, expire_on_commit=True): """ Configure application before each test. set up database transaction. @@ -270,9 +274,15 @@ def setUp(self): self._db_connection = db.engine.connect() self._db_transaction = self._db_connection.begin() - factory = sessionmaker(bind=self._db_connection, binds={}) - self._db_session = scoped_session(factory, current_app._get_current_object) - db.session = self._db_session + factory = sessionmaker( + bind=self._db_connection, + binds={}, + expire_on_commit=expire_on_commit, + ) + self._db_session = scoped_session( + factory, current_app._get_current_object + ) + db.session = self._db_session self.generate_fixture_user() self.log_in_admin() diff --git a/tests/chats/test_chat_routes.py b/tests/chats/test_chat_routes.py index 09edc62ff2..d66603d5bd 100644 --- a/tests/chats/test_chat_routes.py +++ b/tests/chats/test_chat_routes.py @@ -1,11 +1,15 @@ +import os + from tests.base import ApiDBTestCase from zou.app.services import chats_service +from zou.app.stores import file_store +from zou.app.utils import thumbnail class EventsRoutesTestCase(ApiDBTestCase): def setUp(self): - super(EventsRoutesTestCase, self).setUp() + super(EventsRoutesTestCase, self).setUp(expire_on_commit=False) self.generate_fixture_project_status() self.generate_fixture_project() @@ -63,7 +67,7 @@ def test_get_chat_message(self): ) self.assertEqual(message["id"], chat_message["id"]) - """ def test_post_chat_message_with_attachment(self): + def test_post_chat_message_with_attachment(self): self.post(f"/actions/user/chats/{self.asset.id}/join", {}, 200) file_path_fixture = self.get_fixture_file_path( os.path.join("thumbnails", "th01.png"), @@ -81,7 +85,7 @@ def test_get_chat_message(self): size = thumbnail.get_dimensions( file_store.get_local_picture_path("thumbnails", attachment_id) ) - self.assertEqual(size, (150, 150)) """ + self.assertEqual(size, (150, 150)) def test_delete_chat_message(self): chat_message = self.generate_fixture_chat_message()