1+ import  time 
2+ 
13import  pytest 
24
35from  nimbus .pages .experimenter .home  import  HomePage 
@@ -20,7 +22,7 @@ def test_create_new_experiment_approve_remote_settings(
2022    summary  =  SummaryPage (selenium , experiment_url ).open ()
2123    summary .launch_and_approve ()
2224
23-     kinto_client .approve ()
25+     kinto_client () .approve ()
2426
2527    SummaryPage (selenium , experiment_url ).open ().wait_for_live_status ()
2628
@@ -44,7 +46,7 @@ def test_create_new_rollout_approve_remote_settings(
4446    summary  =  SummaryPage (selenium , experiment_url ).open ()
4547    summary .launch_and_approve ()
4648
47-     kinto_client .approve ()
49+     kinto_client () .approve ()
4850
4951    SummaryPage (selenium , experiment_url ).open ().wait_for_live_status ()
5052
@@ -65,7 +67,7 @@ def test_create_new_experiment_reject_remote_settings(
6567    summary  =  SummaryPage (selenium , experiment_url ).open ()
6668    summary .launch_and_approve ()
6769
68-     kinto_client .reject ()
70+     kinto_client () .reject ()
6971
7072    SummaryPage (selenium , experiment_url ).open ().wait_for_rejected_alert ()
7173
@@ -86,7 +88,7 @@ def test_create_new_rollout_reject_remote_settings(
8688    summary  =  SummaryPage (selenium , experiment_url ).open ()
8789    summary .launch_and_approve ()
8890
89-     kinto_client .reject ()
91+     kinto_client () .reject ()
9092
9193    SummaryPage (selenium , experiment_url ).open ().wait_for_rejected_alert ()
9294
@@ -105,13 +107,13 @@ def test_end_experiment_and_approve_end_set_takeaways(
105107    summary  =  SummaryPage (selenium , experiment_url ).open ()
106108    summary .launch_and_approve ()
107109
108-     kinto_client .approve ()
110+     kinto_client () .approve ()
109111
110112    summary  =  SummaryPage (selenium , experiment_url ).open ()
111113    summary .wait_for_live_status ()
112114    summary .end_and_approve ()
113115
114-     kinto_client .approve ()
116+     kinto_client () .approve ()
115117
116118    summary  =  SummaryPage (selenium , experiment_url ).open ()
117119    summary .wait_for_complete_status ()
@@ -139,13 +141,13 @@ def test_end_rollout_and_approve_end_set_takeaways(
139141    summary  =  SummaryPage (selenium , experiment_url ).open ()
140142    summary .launch_and_approve ()
141143
142-     kinto_client .approve ()
144+     kinto_client () .approve ()
143145
144146    summary  =  SummaryPage (selenium , experiment_url ).open ()
145147    summary .wait_for_live_status ()
146148    summary .end_and_approve ()
147149
148-     kinto_client .approve ()
150+     kinto_client () .approve ()
149151
150152    summary  =  SummaryPage (selenium , experiment_url ).open ()
151153    summary .wait_for_complete_status ()
@@ -171,13 +173,13 @@ def test_end_experiment_and_reject_end(
171173    summary  =  SummaryPage (selenium , experiment_url ).open ()
172174    summary .launch_and_approve ()
173175
174-     kinto_client .approve ()
176+     kinto_client () .approve ()
175177
176178    summary  =  SummaryPage (selenium , experiment_url ).open ()
177179    summary .wait_for_live_status ()
178180    summary .end_and_approve ()
179181
180-     kinto_client .reject ()
182+     kinto_client () .reject ()
181183
182184    SummaryPage (selenium , experiment_url ).open ().wait_for_rejected_alert ()
183185
@@ -198,13 +200,13 @@ def test_end_rollout_and_reject_end(
198200    summary  =  SummaryPage (selenium , experiment_url ).open ()
199201    summary .launch_and_approve ()
200202
201-     kinto_client .approve ()
203+     kinto_client () .approve ()
202204
203205    summary  =  SummaryPage (selenium , experiment_url ).open ()
204206    summary .wait_for_live_status ()
205207    summary .end_and_approve ()
206208
207-     kinto_client .reject ()
209+     kinto_client () .reject ()
208210
209211    SummaryPage (selenium , experiment_url ).open ().wait_for_rejected_alert ()
210212
@@ -225,7 +227,7 @@ def test_rollout_live_update_approve(
225227    summary  =  SummaryPage (selenium , experiment_url ).open ()
226228    summary .launch_and_approve ()
227229
228-     kinto_client .approve ()
230+     kinto_client () .approve ()
229231    summary  =  SummaryPage (selenium , experiment_url ).open ()
230232
231233    summary .wait_for_live_status ()
@@ -236,7 +238,7 @@ def test_rollout_live_update_approve(
236238
237239    summary .wait_for_update_request_visible ()
238240    summary .request_update_and_approve ()
239-     kinto_client .approve ()
241+     kinto_client () .approve ()
240242
241243
242244@pytest .mark .remote_settings_all  
@@ -255,7 +257,7 @@ def test_rollout_live_update_approve_and_reject(
255257    summary  =  SummaryPage (selenium , experiment_url ).open ()
256258    summary .launch_and_approve ()
257259
258-     kinto_client .approve ()
260+     kinto_client () .approve ()
259261    summary  =  SummaryPage (selenium , experiment_url ).open ()
260262
261263    summary .wait_for_live_status ()
@@ -267,7 +269,7 @@ def test_rollout_live_update_approve_and_reject(
267269    summary .wait_for_update_request_visible ()
268270
269271    summary .request_update_and_approve ()
270-     kinto_client .reject ()
272+     kinto_client () .reject ()
271273
272274    summary .wait_for_rejection_notice_visible ()
273275
@@ -288,7 +290,7 @@ def test_rollout_live_update_reject_on_experimenter(
288290    summary  =  SummaryPage (selenium , experiment_url ).open ()
289291    summary .launch_and_approve ()
290292
291-     kinto_client .approve ()
293+     kinto_client () .approve ()
292294    summary  =  SummaryPage (selenium , experiment_url ).open ()
293295
294296    summary .wait_for_live_status ()
@@ -320,3 +322,41 @@ def test_create_new_experiment_timeout_remote_settings(
320322    summary  =  SummaryPage (selenium , experiment_url ).open ()
321323    summary .launch_and_approve ()
322324    summary .wait_for_timeout_alert ()
325+ 
326+ 
327+ @pytest .mark .remote_settings_launch  
328+ def  test_create_new_experiment_publish_to_preview_and_unpublish (
329+     selenium ,
330+     experiment_url ,
331+     kinto_client ,
332+     base_url ,
333+     application ,
334+     default_data_api ,
335+     experiment_slug ,
336+ ):
337+     timeout  =  time .time () +  120 
338+     records_before  =  len (kinto_client (collection = "nimbus-preview" ).get_record_data ())
339+ 
340+     helpers .create_experiment (experiment_slug , application , default_data_api )
341+ 
342+     summary  =  SummaryPage (selenium , experiment_url ).open ()
343+     summary .launch_to_preview ()
344+ 
345+     while  time .time () <  timeout :
346+         preview_data  =  kinto_client (collection = "nimbus-preview" ).get_record_data ()
347+         if  any (record .get ("slug" ) ==  experiment_slug  for  record  in  preview_data ):
348+             break 
349+         time .sleep (15 )
350+     else :
351+         pytest .fail ("Experiment not published to preview in time" )
352+ 
353+     summary  =  SummaryPage (selenium , experiment_url ).open ()
354+     summary .back_to_draft ()
355+ 
356+     while  time .time () <  timeout :
357+         records_after  =  kinto_client (collection = "nimbus-preview" ).get_record_data ()
358+         if  len (records_after ) ==  records_before :
359+             break 
360+         time .sleep (15 )
361+     else :
362+         pytest .fail ("Experiment not unpublished from preview in time" )
0 commit comments