@@ -650,54 +650,52 @@ def test_run_junit_import_basic(self, make_import, flask_app):
650650 </testsuite>
651651 """
652652
653- import_record = make_import (filename = "test.xml" , format = "junit" , status = "pending" )
653+ import_record = make_import (filename = "test.xml" , format = "junit" , status = "pending" )
654654
655- # Create import file
656- import_file = ImportFile (
657- id = str (uuid4 ()), import_id = import_record .id , filename = "test.xml" , content = junit_xml
658- )
659- from ibutsu_server .db .base import session
655+ # Create import file
656+ import_file = ImportFile (id = str (uuid4 ()), import_id = import_record .id , content = junit_xml )
657+ from ibutsu_server .db .base import session
660658
661- session .add (import_file )
662- session .commit ()
659+ session .add (import_file )
660+ session .commit ()
663661
664- # Run the import
665- run_junit_import ({"id" : str (import_record .id )})
662+ # Run the import
663+ run_junit_import ({"id" : str (import_record .id )})
666664
667- # Verify run was created
668- runs = Run .query .all ()
669- assert len (runs ) > 0
670- run = runs [- 1 ] # Get the latest run
671- assert run .summary ["tests" ] == 2
672- assert run .summary ["failures" ] == 1
665+ # Verify run was created
666+ runs = Run .query .all ()
667+ assert len (runs ) > 0
668+ run = runs [- 1 ] # Get the latest run
669+ assert run .summary ["tests" ] == 2
670+ assert run .summary ["failures" ] == 1
673671
674- # Verify results were created
675- results = Result .query .filter_by (run_id = run .id ).order_by (Result .id ).all ()
676- assert len (results ) == 2
672+ # Verify results were created
673+ results = Result .query .filter_by (run_id = run .id ).order_by (Result .id ).all ()
674+ assert len (results ) == 2
677675
678- # Verify per-test behavior: one passed and one failed result
679- statuses = {r .result for r in results }
680- assert statuses == {"passed" , "failed" }
676+ # Verify per-test behavior: one passed and one failed result
677+ statuses = {r .result for r in results }
678+ assert statuses == {"passed" , "failed" }
681679
682- # Check that test identifiers/names were correctly mapped from the XML
683- test_ids = {r .test_id for r in results }
684- # Test IDs should contain both test case names
685- assert any ("test_pass" in tid for tid in test_ids )
686- assert any ("test_fail" in tid for tid in test_ids )
680+ # Check that test identifiers/names were correctly mapped from the XML
681+ test_ids = {r .test_id for r in results }
682+ # Test IDs should contain both test case names
683+ assert any ("test_pass" in tid for tid in test_ids )
684+ assert any ("test_fail" in tid for tid in test_ids )
687685
688- # Verify the failed test has a traceback artifact attached
689- failed_result = next (r for r in results if r .result == "failed" )
690- failed_artifacts = Artifact .query .filter_by (result_id = failed_result .id ).all ()
691- failed_filenames = {a .filename for a in failed_artifacts }
686+ # Verify the failed test has a traceback artifact attached
687+ failed_result = next (r for r in results if r .result == "failed" )
688+ failed_artifacts = Artifact .query .filter_by (result_id = failed_result .id ).all ()
689+ failed_filenames = {a .filename for a in failed_artifacts }
692690
693- # We expect a traceback artifact for the failed test
694- assert "traceback.log" in failed_filenames
691+ # We expect a traceback artifact for the failed test
692+ assert "traceback.log" in failed_filenames
695693
696- # Verify import status updated
697- from ibutsu_server .db .models import Import
694+ # Verify import status updated
695+ from ibutsu_server .db .models import Import
698696
699- updated_import = Import .query .get (import_record .id )
700- assert updated_import .status == "done"
697+ updated_import = Import .query .get (import_record .id )
698+ assert updated_import .status == "done"
701699
702700 def test_run_junit_import_with_properties (self , make_import , make_project , flask_app ):
703701 """Test JUnit import with properties"""
@@ -723,9 +721,7 @@ def test_run_junit_import_with_properties(self, make_import, make_project, flask
723721 data = {"project_id" : project .id },
724722 )
725723
726- import_file = ImportFile (
727- id = str (uuid4 ()), import_id = import_record .id , filename = "test.xml" , content = junit_xml
728- )
724+ import_file = ImportFile (id = str (uuid4 ()), import_id = import_record .id , content = junit_xml )
729725 from ibutsu_server .db .base import session
730726
731727 session .add (import_file )
@@ -809,7 +805,6 @@ def test_run_archive_import_basic(self, make_import, flask_app):
809805 import_file = ImportFile (
810806 id = str (uuid4 ()),
811807 import_id = import_record .id ,
812- filename = "archive.tar.gz" ,
813808 content = tar_content ,
814809 )
815810 from ibutsu_server .db .base import session
@@ -825,8 +820,8 @@ def test_run_archive_import_basic(self, make_import, flask_app):
825820 run = Run .query .get (run_id )
826821 assert run is not None
827822
828- # Verify result was created
829- result = Result .query .get ( result_id )
823+ # Verify result was created (archive import creates new IDs for results)
824+ result = Result .query .filter_by ( test_id = "test.example" , run_id = run . id ). first ( )
830825 assert result is not None
831826 assert result .test_id == "test.example"
832827
0 commit comments