17
17
import pytest
18
18
19
19
import tmt
20
+ import tmt .config
20
21
import tmt .log
21
22
import tmt .plugins
22
23
import tmt .steps .discover
@@ -204,56 +205,6 @@ def test_inject_auth_git_url(monkeypatch) -> None:
204
205
inject_auth_git_url ('https://example.com/broken/something' )
205
206
206
207
207
- def test_config ():
208
- """ Config smoke test """
209
- run = Path ('/var/tmp/tmt/test' )
210
- config1 = tmt .utils .Config ()
211
- config1 .last_run = run
212
- config2 = tmt .utils .Config ()
213
- assert config2 .last_run .resolve () == run .resolve ()
214
-
215
-
216
- def test_last_run_race (tmppath : Path , monkeypatch ):
217
- """ Race in last run symlink shouldn't be fatal """
218
- config_path = tmppath / 'config'
219
- config_path .mkdir ()
220
- monkeypatch .setattr (tmt .utils , 'effective_config_dir' , MagicMock (return_value = config_path ))
221
- mock_logger = unittest .mock .MagicMock ()
222
- monkeypatch .setattr (tmt .utils .log , 'warning' , mock_logger )
223
- config = tmt .utils .Config ()
224
- results = queue .Queue ()
225
- threads = []
226
-
227
- def create_last_run (config , counter ):
228
- try :
229
- last_run_path = tmppath / f"run-{ counter } "
230
- last_run_path .mkdir ()
231
- val = config .last_run = last_run_path
232
- results .put (val )
233
- except Exception as err :
234
- results .put (err )
235
-
236
- total = 20
237
- for i in range (total ):
238
- threads .append (threading .Thread (target = create_last_run , args = (config , i )))
239
- for t in threads :
240
- t .start ()
241
- for t in threads :
242
- t .join ()
243
-
244
- all_good = True
245
- for _ in threads :
246
- value = results .get ()
247
- if isinstance (value , Exception ):
248
- # Print exception for logging
249
- print (value )
250
- all_good = False
251
- assert all_good
252
- # Getting into race is not certain, do not assert
253
- # assert mock_logger.called
254
- assert config .last_run , "Some run was stored as last run"
255
-
256
-
257
208
def test_workdir_env_var (tmppath : Path , monkeypatch , root_logger ):
258
209
""" Test TMT_WORKDIR_ROOT environment variable """
259
210
# Cannot use monkeypatch.context() as it is not present for CentOS Stream 8
@@ -1737,9 +1688,9 @@ def tearDown(self):
1737
1688
shutil .rmtree (self .tmp )
1738
1689
1739
1690
@unittest .mock .patch ('jira.JIRA.add_simple_link' )
1740
- @unittest .mock .patch ('tmt.utils .Config' )
1691
+ @unittest .mock .patch ('tmt.config .Config.fmf_tree' , new_callable = unittest . mock . PropertyMock )
1741
1692
def test_jira_link_test_only (self , mock_config_tree , mock_add_simple_link ) -> None :
1742
- mock_config_tree .return_value . fmf_tree = self .config_tree
1693
+ mock_config_tree .return_value = self .config_tree
1743
1694
test = tmt .Tree (logger = self .logger , path = self .tmp ).tests (names = ['tmp/test' ])[0 ]
1744
1695
tmt .utils .jira .link (
1745
1696
tmt_objects = [test ],
@@ -1752,9 +1703,9 @@ def test_jira_link_test_only(self, mock_config_tree, mock_add_simple_link) -> No
1752
1703
assert '&test-path=%2Ftests%2Funit%2Ftmp' in result ['url' ]
1753
1704
1754
1705
@unittest .mock .patch ('jira.JIRA.add_simple_link' )
1755
- @unittest .mock .patch ('tmt.utils .Config' )
1706
+ @unittest .mock .patch ('tmt.config .Config.fmf_tree' , new_callable = unittest . mock . PropertyMock )
1756
1707
def test_jira_link_test_plan_story (self , mock_config_tree , mock_add_simple_link ) -> None :
1757
- mock_config_tree .return_value . fmf_tree = self .config_tree
1708
+ mock_config_tree .return_value = self .config_tree
1758
1709
test = tmt .Tree (logger = self .logger , path = self .tmp ).tests (names = ['tmp/test' ])[0 ]
1759
1710
plan = tmt .Tree (logger = self .logger , path = self .tmp ).plans (names = ['tmp' ])[0 ]
1760
1711
story = tmt .Tree (logger = self .logger , path = self .tmp ).stories (names = ['tmp' ])[0 ]
@@ -1778,9 +1729,9 @@ def test_jira_link_test_plan_story(self, mock_config_tree, mock_add_simple_link)
1778
1729
assert '&story-path=%2Ftests%2Funit%2Ftmp' in result ['url' ]
1779
1730
1780
1731
@unittest .mock .patch ('jira.JIRA.add_simple_link' )
1781
- @unittest .mock .patch ('tmt.utils .Config' )
1732
+ @unittest .mock .patch ('tmt.config .Config.fmf_tree' , new_callable = unittest . mock . PropertyMock )
1782
1733
def test_create_link_relation (self , mock_config_tree , mock_add_simple_link ) -> None :
1783
- mock_config_tree .return_value . fmf_tree = self .config_tree
1734
+ mock_config_tree .return_value = self .config_tree
1784
1735
test = tmt .Tree (logger = self .logger , path = self .tmp ).tests (names = ['tmp/test' ])[0 ]
1785
1736
tmt .utils .jira .link (
1786
1737
tmt_objects = [test ],
0 commit comments