@@ -52,6 +52,69 @@ def project(tmp_path: str):
52
52
return project
53
53
54
54
55
+ @pytest .fixture
56
+ def project_use_docker (tmp_path : str ):
57
+ project_use_docker = Project (root = tmp_path )
58
+
59
+ patch_plugins = patch .dict (
60
+ "rpdk.core.plugin_registry.PLUGIN_REGISTRY" ,
61
+ {TypescriptLanguagePlugin .NAME : lambda : TypescriptLanguagePlugin },
62
+ clear = True ,
63
+ )
64
+ with patch_plugins :
65
+ current_path = os .path .abspath (__file__ )
66
+ lib_abspath = os .path .abspath (os .path .join (current_path , ".." , ".." , ".." ))
67
+ TypescriptLanguagePlugin .SUPPORT_LIB_URI = f"file:{ lib_abspath } "
68
+ project_use_docker .init (
69
+ TYPE_NAME ,
70
+ TypescriptLanguagePlugin .NAME ,
71
+ settings = {"use_docker" : True , "no_docker" : False },
72
+ )
73
+ return project_use_docker
74
+
75
+
76
+ @pytest .fixture
77
+ def project_no_docker (tmp_path : str ):
78
+ project_no_docker = Project (root = tmp_path )
79
+
80
+ patch_plugins = patch .dict (
81
+ "rpdk.core.plugin_registry.PLUGIN_REGISTRY" ,
82
+ {TypescriptLanguagePlugin .NAME : lambda : TypescriptLanguagePlugin },
83
+ clear = True ,
84
+ )
85
+ with patch_plugins :
86
+ current_path = os .path .abspath (__file__ )
87
+ lib_abspath = os .path .abspath (os .path .join (current_path , ".." , ".." , ".." ))
88
+ TypescriptLanguagePlugin .SUPPORT_LIB_URI = f"file:{ lib_abspath } "
89
+ project_no_docker .init (
90
+ TYPE_NAME ,
91
+ TypescriptLanguagePlugin .NAME ,
92
+ settings = {"use_docker" : False , "no_docker" : True },
93
+ )
94
+ return project_no_docker
95
+
96
+
97
+ @pytest .fixture
98
+ def project_both_true (tmp_path : str ):
99
+ project_both_true = Project (root = tmp_path )
100
+
101
+ patch_plugins = patch .dict (
102
+ "rpdk.core.plugin_registry.PLUGIN_REGISTRY" ,
103
+ {TypescriptLanguagePlugin .NAME : lambda : TypescriptLanguagePlugin },
104
+ clear = True ,
105
+ )
106
+ with patch_plugins :
107
+ current_path = os .path .abspath (__file__ )
108
+ lib_abspath = os .path .abspath (os .path .join (current_path , ".." , ".." , ".." ))
109
+ TypescriptLanguagePlugin .SUPPORT_LIB_URI = f"file:{ lib_abspath } "
110
+ project_both_true .init (
111
+ TYPE_NAME ,
112
+ TypescriptLanguagePlugin .NAME ,
113
+ settings = {"use_docker" : True , "no_docker" : True },
114
+ )
115
+ return project_both_true
116
+
117
+
55
118
def get_files_in_project (project : Project ):
56
119
return {
57
120
str (child .relative_to (project .root )): child for child in project .root .rglob ("*" )
@@ -92,11 +155,35 @@ def test__remove_build_artifacts_file_not_found(tmp_path: str):
92
155
mock_log .debug .assert_called_once ()
93
156
94
157
95
- def test_initialize (project : Project ):
96
- lib_path = project ._plugin ._lib_path
97
- assert project .settings == {"use_docker" : False , "protocolVersion" : "2.0.0" }
158
+ @pytest .fixture
159
+ def project_no_docker_use_docker_values (
160
+ request , project , project_use_docker , project_no_docker , project_both_true
161
+ ):
162
+ return [
163
+ (project , True , False ),
164
+ (project_use_docker , False , True ),
165
+ (project_no_docker , True , False ),
166
+ (project_both_true , False , True ),
167
+ ][request .param ]
168
+
169
+
170
+ @pytest .mark .parametrize (
171
+ "project_no_docker_use_docker_values" , [0 , 1 , 2 , 3 ], indirect = True
172
+ )
173
+ def test_initialize (project_no_docker_use_docker_values ):
174
+ (
175
+ project_value ,
176
+ no_docker_value ,
177
+ use_docker_value ,
178
+ ) = project_no_docker_use_docker_values
179
+ lib_path = project_value ._plugin ._lib_path
180
+ assert project_value .settings == {
181
+ "protocolVersion" : "2.0.0" ,
182
+ "no_docker" : no_docker_value ,
183
+ "use_docker" : use_docker_value ,
184
+ }
98
185
99
- files = get_files_in_project (project )
186
+ files = get_files_in_project (project_value )
100
187
assert set (files ) == {
101
188
".gitignore" ,
102
189
".npmrc" ,
@@ -122,12 +209,12 @@ def test_initialize(project: Project):
122
209
assert lib_path in package_json
123
210
124
211
readme = files ["README.md" ].read_text ()
125
- assert project .type_name in readme
212
+ assert project_value .type_name in readme
126
213
assert SUPPORT_LIB_NAME in readme
127
214
assert "handlers.ts" in readme
128
215
assert "models.ts" in readme
129
216
130
- assert project .entrypoint in files ["template.yml" ].read_text ()
217
+ assert project_value .entrypoint in files ["template.yml" ].read_text ()
131
218
132
219
133
220
def test_generate (project : Project ):
0 commit comments