@@ -42,48 +42,53 @@ def log_messages(caplog):
42
42
43
43
44
44
@pytest .fixture
45
- def create_test_run () -> typing .Generator [typing .Tuple [sv_run .Run , dict ], None , None ]:
45
+ def create_test_run (request ) -> typing .Generator [typing .Tuple [sv_run .Run , dict ], None , None ]:
46
46
with sv_run .Run () as run :
47
- yield run , setup_test_run (run , True )
47
+ yield run , setup_test_run (run , True , request )
48
48
49
49
50
50
@pytest .fixture
51
- def create_test_run_offline (mocker : pytest_mock .MockerFixture ) -> typing .Generator [typing .Tuple [sv_run .Run , dict ], None , None ]:
51
+ def create_test_run_offline (mocker : pytest_mock .MockerFixture , request ) -> typing .Generator [typing .Tuple [sv_run .Run , dict ], None , None ]:
52
52
with tempfile .TemporaryDirectory () as temp_d :
53
53
mocker .patch .object (simvue .utilities , "get_offline_directory" , lambda * _ : temp_d )
54
54
with sv_run .Run ("offline" ) as run :
55
- yield run , setup_test_run (run , True )
55
+ yield run , setup_test_run (run , True , request )
56
56
57
57
58
58
@pytest .fixture
59
- def create_plain_run () -> typing .Generator [typing .Tuple [sv_run .Run , dict ], None , None ]:
59
+ def create_plain_run (request ) -> typing .Generator [typing .Tuple [sv_run .Run , dict ], None , None ]:
60
60
with sv_run .Run () as run :
61
- yield run , setup_test_run (run , False )
61
+ yield run , setup_test_run (run , False , request )
62
62
63
63
64
64
@pytest .fixture
65
- def create_plain_run_offline (mocker : pytest_mock .MockerFixture ) -> typing .Generator [typing .Tuple [sv_run .Run , dict ], None , None ]:
65
+ def create_plain_run_offline (mocker : pytest_mock .MockerFixture , request ) -> typing .Generator [typing .Tuple [sv_run .Run , dict ], None , None ]:
66
66
with tempfile .TemporaryDirectory () as temp_d :
67
67
mocker .patch .object (simvue .utilities , "get_offline_directory" , lambda * _ : temp_d )
68
68
with sv_run .Run ("offline" ) as run :
69
69
70
- yield run , setup_test_run (run , False )
70
+ yield run , setup_test_run (run , False , request )
71
71
72
72
73
- def setup_test_run (run : sv_run .Run , create_objects : bool ):
73
+ def setup_test_run (run : sv_run .Run , create_objects : bool , request : pytest . FixtureRequest ):
74
74
fix_use_id : str = str (uuid .uuid4 ()).split ('-' , 1 )[0 ]
75
75
TEST_DATA = {
76
76
"event_contains" : "sent event" ,
77
77
"metadata" : {
78
78
"test_engine" : "pytest" ,
79
79
"test_identifier" : fix_use_id
80
80
},
81
- "folder" : f"/simvue_unit_testing/{ fix_use_id } "
81
+ "folder" : f"/simvue_unit_testing/{ fix_use_id } " ,
82
+ "tags" : ["simvue_client_unit_tests" , request .node .name ]
82
83
}
84
+
85
+ if os .environ .get ("CI" ):
86
+ TEST_DATA ["tags" ].append ("ci" )
87
+
83
88
run .config (suppress_errors = False )
84
89
run .init (
85
90
name = f"test_run_{ TEST_DATA ['metadata' ]['test_identifier' ]} " ,
86
- tags = [ "simvue_client_unit_tests " ],
91
+ tags = TEST_DATA [ "tags " ],
87
92
folder = TEST_DATA ["folder" ],
88
93
visibility = "tenant" ,
89
94
retention_period = "1 hour"
0 commit comments