55import git
66import pytest
77
8+ from kcidev .subcommands .config import add_config
89
9- def test_prepare ():
10+
11+ @pytest .fixture (scope = "session" )
12+ def kcidev_config (tmpdir_factory ):
13+ file = tmpdir_factory .mktemp ("config" ).join (".kci-dev.toml" )
1014 # prepare enviroment
11- os .system ("cp .kci-dev.toml.example .kci-dev.toml" )
12- assert os .path .exists (".kci-dev.toml" )
15+ command = ["poetry" , "run" , "kci-dev" , "config" , "--file-path" , file ]
16+ result = run (command , stdout = PIPE , stderr = PIPE , universal_newlines = True )
17+ return file
1318
1419
1520def test_kcidev_help ():
@@ -23,8 +28,16 @@ def test_kcidev_help():
2328 assert result .returncode == 0
2429
2530
26- def test_kcidev_commit_help ():
27- command = ["poetry" , "run" , "kci-dev" , "commit" , "--help" ]
31+ def test_kcidev_commit_help (kcidev_config ):
32+ command = [
33+ "poetry" ,
34+ "run" ,
35+ "kci-dev" ,
36+ "--settings" ,
37+ kcidev_config ,
38+ "commit" ,
39+ "--help" ,
40+ ]
2841 result = run (command , stdout = PIPE , stderr = PIPE , universal_newlines = True )
2942 print ("returncode: " + str (result .returncode ))
3043 print ("#### stdout ####" )
@@ -34,8 +47,16 @@ def test_kcidev_commit_help():
3447 assert result .returncode == 0
3548
3649
37- def test_kcidev_patch_help ():
38- command = ["poetry" , "run" , "kci-dev" , "patch" , "--help" ]
50+ def test_kcidev_patch_help (kcidev_config ):
51+ command = [
52+ "poetry" ,
53+ "run" ,
54+ "kci-dev" ,
55+ "--settings" ,
56+ kcidev_config ,
57+ "patch" ,
58+ "--help" ,
59+ ]
3960 result = run (command , stdout = PIPE , stderr = PIPE , universal_newlines = True )
4061 print ("returncode: " + str (result .returncode ))
4162 print ("#### stdout ####" )
@@ -45,8 +66,16 @@ def test_kcidev_patch_help():
4566 assert result .returncode == 0
4667
4768
48- def test_kcidev_results_help ():
49- command = ["poetry" , "run" , "kci-dev" , "maestro-results" , "--help" ]
69+ def test_kcidev_results_help (kcidev_config ):
70+ command = [
71+ "poetry" ,
72+ "run" ,
73+ "kci-dev" ,
74+ "--settings" ,
75+ kcidev_config ,
76+ "maestro-results" ,
77+ "--help" ,
78+ ]
5079 result = run (command , stdout = PIPE , stderr = PIPE , universal_newlines = True )
5180 print ("returncode: " + str (result .returncode ))
5281 print ("#### stdout ####" )
@@ -56,8 +85,16 @@ def test_kcidev_results_help():
5685 assert result .returncode == 0
5786
5887
59- def test_kcidev_testretry_help ():
60- command = ["poetry" , "run" , "kci-dev" , "testretry" , "--help" ]
88+ def test_kcidev_testretry_help (kcidev_config ):
89+ command = [
90+ "poetry" ,
91+ "run" ,
92+ "kci-dev" ,
93+ "--settings" ,
94+ kcidev_config ,
95+ "testretry" ,
96+ "--help" ,
97+ ]
6198 result = run (command , stdout = PIPE , stderr = PIPE , universal_newlines = True )
6299 print ("returncode: " + str (result .returncode ))
63100 print ("#### stdout ####" )
@@ -67,8 +104,16 @@ def test_kcidev_testretry_help():
67104 assert result .returncode == 0
68105
69106
70- def test_kcidev_checkout_help ():
71- command = ["poetry" , "run" , "kci-dev" , "checkout" , "--help" ]
107+ def test_kcidev_checkout_help (kcidev_config ):
108+ command = [
109+ "poetry" ,
110+ "run" ,
111+ "kci-dev" ,
112+ "--settings" ,
113+ kcidev_config ,
114+ "checkout" ,
115+ "--help" ,
116+ ]
72117 result = run (command , stdout = PIPE , stderr = PIPE , universal_newlines = True )
73118 print ("returncode: " + str (result .returncode ))
74119 print ("#### stdout ####" )
@@ -78,11 +123,13 @@ def test_kcidev_checkout_help():
78123 assert result .returncode == 0
79124
80125
81- def test_kcidev_results_tests ():
126+ def test_kcidev_results_tests (kcidev_config ):
82127 command = [
83128 "poetry" ,
84129 "run" ,
85130 "kci-dev" ,
131+ "--settings" ,
132+ kcidev_config ,
86133 "--instance" ,
87134 "staging" ,
88135 "maestro-results" ,
@@ -112,11 +159,13 @@ def test_create_repo():
112159 r .index .commit ("test" )
113160
114161
115- def test_kcidev_commit ():
162+ def test_kcidev_commit (kcidev_config ):
116163 command = [
117164 "poetry" ,
118165 "run" ,
119166 "kci-dev" ,
167+ "--settings" ,
168+ kcidev_config ,
120169 "--instance" ,
121170 "staging" ,
122171 "commit" ,
@@ -149,8 +198,3 @@ def test_main():
149198def test_clean ():
150199 # clean enviroment
151200 shutil .rmtree ("my-new-repo/" )
152-
153- if os .path .isfile (".kci-dev.toml" ):
154- os .remove (".kci-dev.toml" )
155- else :
156- print ("File does not exist" )
0 commit comments