Skip to content

Commit

Permalink
fix: lru_cache returning messing up tests
Browse files Browse the repository at this point in the history
  • Loading branch information
righel committed Dec 23, 2024
1 parent 549e0b8 commit 00dea14
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 0 additions & 3 deletions api/app/repositories/tags.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from functools import lru_cache

from app.models import attribute as attribute_models
from app.models import event as event_models
from app.models import tag as tag_models
Expand Down Expand Up @@ -148,7 +146,6 @@ def capture_tag(db: Session, tag: MISPTag, user: user_models.User) -> tag_models
return db_tag


@lru_cache
def get_tag_by_name(db: Session, tag_name: str):
return (
db.query(tag_models.Tag)
Expand Down
8 changes: 7 additions & 1 deletion api/app/tests/api_tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from app.models import attribute as attribute_models
from app.models import event as event_models
from app.models import feed as feed_models
from app.models import galaxy as galaxy_models
from app.models import module as module_models
from app.models import object as object_models
from app.models import object_reference as object_reference_models
Expand Down Expand Up @@ -58,6 +59,11 @@ def settings(self):
yield get_settings()

def teardown_db(self, db: Session):
db.query(galaxy_models.GalaxyElement).delete()
db.query(galaxy_models.GalaxyClusterRelationTag).delete()
db.query(galaxy_models.GalaxyClusterRelation).delete()
db.query(galaxy_models.GalaxyCluster).delete()
db.query(galaxy_models.Galaxy).delete()
db.query(feed_models.Feed).delete()
db.query(tag_models.AttributeTag).delete()
db.query(tag_models.EventTag).delete()
Expand All @@ -71,11 +77,11 @@ def teardown_db(self, db: Session):
db.query(sharing_groups_models.SharingGroup).delete()
db.query(server_models.Server).delete()
db.query(user_models.User).delete()
db.query(organisation_models.Organisation).delete()
db.query(module_models.ModuleSettings).delete()
db.query(taxonomy_models.TaxonomyEntry).delete()
db.query(taxonomy_models.TaxonomyPredicate).delete()
db.query(taxonomy_models.Taxonomy).delete()
db.query(organisation_models.Organisation).delete()

@pytest.fixture(scope="class", autouse=True)
def cleanup(self, db: Session):
Expand Down

0 comments on commit 00dea14

Please sign in to comment.