@@ -1684,7 +1684,11 @@ def test_create_job_with_multiple_faulty_existing_image_inputs(
16841684
16851685@pytest .mark .django_db
16861686def test_algorithm_image_activate (
1687- settings , client , algorithm_io_image , mocker
1687+ settings ,
1688+ client ,
1689+ algorithm_io_image ,
1690+ mocker ,
1691+ django_capture_on_commit_callbacks ,
16881692):
16891693 mocker .patch .object (
16901694 AlgorithmImage , "calculate_size_in_registry" , lambda x : 100
@@ -1711,26 +1715,29 @@ def test_algorithm_image_activate(
17111715 editor , user = UserFactory .create_batch (2 )
17121716 alg .add_editor (editor )
17131717
1714- response = get_view_for_user (
1715- viewname = "algorithms:image-activate" ,
1716- client = client ,
1717- method = client .post ,
1718- reverse_kwargs = {"slug" : alg .slug },
1719- data = {"algorithm_image" : i1 .pk },
1720- user = user ,
1721- follow = True ,
1722- )
1718+ with django_capture_on_commit_callbacks (execute = True ):
1719+ response = get_view_for_user (
1720+ viewname = "algorithms:image-activate" ,
1721+ client = client ,
1722+ method = client .post ,
1723+ reverse_kwargs = {"slug" : alg .slug },
1724+ data = {"algorithm_image" : i1 .pk },
1725+ user = user ,
1726+ follow = True ,
1727+ )
1728+
17231729 assert response .status_code == 403
17241730
1725- response2 = get_view_for_user (
1726- viewname = "algorithms:image-activate" ,
1727- client = client ,
1728- method = client .post ,
1729- reverse_kwargs = {"slug" : alg .slug },
1730- data = {"algorithm_image" : i1 .pk },
1731- user = editor ,
1732- follow = True ,
1733- )
1731+ with django_capture_on_commit_callbacks (execute = True ):
1732+ response2 = get_view_for_user (
1733+ viewname = "algorithms:image-activate" ,
1734+ client = client ,
1735+ method = client .post ,
1736+ reverse_kwargs = {"slug" : alg .slug },
1737+ data = {"algorithm_image" : i1 .pk },
1738+ user = editor ,
1739+ follow = True ,
1740+ )
17341741
17351742 assert response2 .status_code == 200
17361743 i1 .refresh_from_db ()
@@ -1743,15 +1750,17 @@ def test_algorithm_image_activate(
17431750 i2 .is_in_registry = False
17441751 i2 .save ()
17451752
1746- response4 = get_view_for_user (
1747- viewname = "algorithms:image-activate" ,
1748- client = client ,
1749- method = client .post ,
1750- reverse_kwargs = {"slug" : alg .slug },
1751- data = {"algorithm_image" : i2 .pk },
1752- user = editor ,
1753- follow = True ,
1754- )
1753+ with django_capture_on_commit_callbacks (execute = True ):
1754+ response4 = get_view_for_user (
1755+ viewname = "algorithms:image-activate" ,
1756+ client = client ,
1757+ method = client .post ,
1758+ reverse_kwargs = {"slug" : alg .slug },
1759+ data = {"algorithm_image" : i2 .pk },
1760+ user = editor ,
1761+ follow = True ,
1762+ )
1763+
17551764 assert response4 .status_code == 200
17561765 assert "Image validation and upload to registry in progress." in str (
17571766 response4 .content
@@ -1760,15 +1769,18 @@ def test_algorithm_image_activate(
17601769 i2 .import_status = ImportStatusChoices .INITIALIZED
17611770 i2 .is_desired_version = False
17621771 i2 .save ()
1763- response6 = get_view_for_user (
1764- viewname = "algorithms:image-activate" ,
1765- client = client ,
1766- method = client .post ,
1767- reverse_kwargs = {"slug" : alg .slug },
1768- data = {"algorithm_image" : i2 .pk },
1769- user = editor ,
1770- follow = True ,
1771- )
1772+
1773+ with django_capture_on_commit_callbacks (execute = True ):
1774+ response6 = get_view_for_user (
1775+ viewname = "algorithms:image-activate" ,
1776+ client = client ,
1777+ method = client .post ,
1778+ reverse_kwargs = {"slug" : alg .slug },
1779+ data = {"algorithm_image" : i2 .pk },
1780+ user = editor ,
1781+ follow = True ,
1782+ )
1783+
17721784 assert response6 .status_code == 200
17731785 i1 .refresh_from_db ()
17741786 i2 .refresh_from_db ()
0 commit comments