@@ -208,3 +208,52 @@ def test_environment_variables_total_size_per_project(self):
208
208
assert resp .json () == [
209
209
"The total size of all environment variables in the project cannot exceed 256 KB."
210
210
]
211
+
212
+ def test_create_environment_variable_with_public_flag (self ):
213
+ self .assertEqual (self .project .environmentvariable_set .count (), 1 )
214
+ data = {
215
+ "name" : "TEST_ENV_VAR" ,
216
+ "value" : "test_value" ,
217
+ "public" : True ,
218
+ }
219
+
220
+ self .client .credentials (HTTP_AUTHORIZATION = f"Token { self .token .key } " )
221
+ response = self .client .post (
222
+ reverse (
223
+ "projects-environmentvariables-list" ,
224
+ kwargs = {
225
+ "parent_lookup_project__slug" : self .project .slug ,
226
+ },
227
+ ),
228
+ data ,
229
+ )
230
+ self .assertEqual (response .status_code , 201 )
231
+ self .assertEqual (self .project .environmentvariable_set .count (), 2 )
232
+
233
+ env_var = self .project .environmentvariable_set .get (name = "TEST_ENV_VAR" )
234
+ self .assertEqual (env_var .value , "test_value" )
235
+ self .assertTrue (env_var .public )
236
+
237
+ def test_create_environment_variable_without_public_flag (self ):
238
+ self .assertEqual (self .project .environmentvariable_set .count (), 1 )
239
+ data = {
240
+ "name" : "TEST_ENV_VAR" ,
241
+ "value" : "test_value" ,
242
+ }
243
+
244
+ self .client .credentials (HTTP_AUTHORIZATION = f"Token { self .token .key } " )
245
+ response = self .client .post (
246
+ reverse (
247
+ "projects-environmentvariables-list" ,
248
+ kwargs = {
249
+ "parent_lookup_project__slug" : self .project .slug ,
250
+ },
251
+ ),
252
+ data ,
253
+ )
254
+ self .assertEqual (response .status_code , 201 )
255
+ self .assertEqual (self .project .environmentvariable_set .count (), 2 )
256
+
257
+ env_var = self .project .environmentvariable_set .get (name = "TEST_ENV_VAR" )
258
+ self .assertEqual (env_var .value , "test_value" )
259
+ self .assertFalse (env_var .public )
0 commit comments