Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 16 additions & 6 deletions tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ class ApiTestCase(unittest.TestCase):
"""
Set of helpers to make test development easier.
"""

@classmethod
def setUpClass(cls):
pass
Expand All @@ -82,6 +83,7 @@ def setUp(self):
app.app_context().push()

from zou.app.utils import cache

cache.clear()

def tearDown(self):
Expand Down Expand Up @@ -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):
"""
Expand All @@ -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()
Expand 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.
Expand All @@ -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()
Expand Down
10 changes: 7 additions & 3 deletions tests/chats/test_chat_routes.py
Original file line number Diff line number Diff line change
@@ -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()
Expand Down Expand Up @@ -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"),
Expand All @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion tests/shots/test_episodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Loading