Skip to content

Commit

Permalink
Fix rollout timeline/pop page fixes #2403 (#2406)
Browse files Browse the repository at this point in the history
* Fix rollout timeline/pop page fixes #2403

* Split into two methods of enrollment and playbook

* Add values to options

Co-authored-by: Jared Lockhart <[email protected]>
  • Loading branch information
2 people authored and tiftran committed Mar 19, 2020
1 parent 629993f commit aabdbb7
Show file tree
Hide file tree
Showing 9 changed files with 236 additions and 23 deletions.
36 changes: 36 additions & 0 deletions app/experimenter/docs/openapi-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -4556,6 +4556,10 @@
"type": "integer",
"nullable": true
},
"rollout_playbook": {
"type": "string",
"nullable": true
},
"proposed_duration": {
"type": "integer",
"nullable": true
Expand Down Expand Up @@ -4662,6 +4666,10 @@
"type": "integer",
"nullable": true
},
"rollout_playbook": {
"type": "string",
"nullable": true
},
"proposed_duration": {
"type": "integer",
"nullable": true
Expand Down Expand Up @@ -4744,6 +4752,10 @@
"type": "integer",
"nullable": true
},
"rollout_playbook": {
"type": "string",
"nullable": true
},
"proposed_duration": {
"type": "integer",
"nullable": true
Expand Down Expand Up @@ -4826,6 +4838,10 @@
"type": "integer",
"nullable": true
},
"rollout_playbook": {
"type": "string",
"nullable": true
},
"proposed_duration": {
"type": "integer",
"nullable": true
Expand Down Expand Up @@ -4913,6 +4929,10 @@
"type": "integer",
"nullable": true
},
"rollout_playbook": {
"type": "string",
"nullable": true
},
"proposed_duration": {
"type": "integer",
"nullable": true
Expand Down Expand Up @@ -5019,6 +5039,10 @@
"type": "integer",
"nullable": true
},
"rollout_playbook": {
"type": "string",
"nullable": true
},
"proposed_duration": {
"type": "integer",
"nullable": true
Expand Down Expand Up @@ -5101,6 +5125,10 @@
"type": "integer",
"nullable": true
},
"rollout_playbook": {
"type": "string",
"nullable": true
},
"proposed_duration": {
"type": "integer",
"nullable": true
Expand Down Expand Up @@ -5183,6 +5211,10 @@
"type": "integer",
"nullable": true
},
"rollout_playbook": {
"type": "string",
"nullable": true
},
"proposed_duration": {
"type": "integer",
"nullable": true
Expand Down Expand Up @@ -5270,6 +5302,10 @@
"type": "integer",
"nullable": true
},
"rollout_playbook": {
"type": "string",
"nullable": true
},
"proposed_duration": {
"type": "integer",
"nullable": true
Expand Down
36 changes: 36 additions & 0 deletions app/experimenter/docs/swagger-ui.html
Original file line number Diff line number Diff line change
Expand Up @@ -4568,6 +4568,10 @@
"type": "integer",
"nullable": true
},
"rollout_playbook": {
"type": "string",
"nullable": true
},
"proposed_duration": {
"type": "integer",
"nullable": true
Expand Down Expand Up @@ -4674,6 +4678,10 @@
"type": "integer",
"nullable": true
},
"rollout_playbook": {
"type": "string",
"nullable": true
},
"proposed_duration": {
"type": "integer",
"nullable": true
Expand Down Expand Up @@ -4756,6 +4764,10 @@
"type": "integer",
"nullable": true
},
"rollout_playbook": {
"type": "string",
"nullable": true
},
"proposed_duration": {
"type": "integer",
"nullable": true
Expand Down Expand Up @@ -4838,6 +4850,10 @@
"type": "integer",
"nullable": true
},
"rollout_playbook": {
"type": "string",
"nullable": true
},
"proposed_duration": {
"type": "integer",
"nullable": true
Expand Down Expand Up @@ -4925,6 +4941,10 @@
"type": "integer",
"nullable": true
},
"rollout_playbook": {
"type": "string",
"nullable": true
},
"proposed_duration": {
"type": "integer",
"nullable": true
Expand Down Expand Up @@ -5031,6 +5051,10 @@
"type": "integer",
"nullable": true
},
"rollout_playbook": {
"type": "string",
"nullable": true
},
"proposed_duration": {
"type": "integer",
"nullable": true
Expand Down Expand Up @@ -5113,6 +5137,10 @@
"type": "integer",
"nullable": true
},
"rollout_playbook": {
"type": "string",
"nullable": true
},
"proposed_duration": {
"type": "integer",
"nullable": true
Expand Down Expand Up @@ -5195,6 +5223,10 @@
"type": "integer",
"nullable": true
},
"rollout_playbook": {
"type": "string",
"nullable": true
},
"proposed_duration": {
"type": "integer",
"nullable": true
Expand Down Expand Up @@ -5282,6 +5314,10 @@
"type": "integer",
"nullable": true
},
"rollout_playbook": {
"type": "string",
"nullable": true
},
"proposed_duration": {
"type": "integer",
"nullable": true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ class ExperimentTimelinePopSerializer(
proposed_enrollment = serializers.IntegerField(
required=False, allow_null=True, default=None
)
rollout_playbook = serializers.CharField(
required=False, allow_null=True, default=None
)
population_percent = serializers.DecimalField(
required=False,
max_digits=7,
Expand Down Expand Up @@ -65,6 +68,7 @@ class Meta:
fields = (
"proposed_start_date",
"proposed_enrollment",
"rollout_playbook",
"proposed_duration",
"population_percent",
"firefox_channel",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def setUp(self):
population_percent="30.0000",
)

def test_serializer_outputs_expected_schema(self):
def test_serializer_outputs_expected_schema_pref(self):

serializer = ExperimentTimelinePopSerializer(self.experiment)

Expand All @@ -58,6 +58,7 @@ def test_serializer_outputs_expected_schema(self):
"proposed_start_date": self.experiment.proposed_start_date.strftime(
"%Y-%m-%d"
),
"rollout_playbook": None,
"proposed_enrollment": self.experiment.proposed_enrollment,
"proposed_duration": self.experiment.proposed_duration,
"population_percent": self.experiment.population_percent,
Expand Down Expand Up @@ -152,3 +153,57 @@ def test_serializer_rejects_enrollment_greater_duration(self):

self.assertFalse(serializer.is_valid())
self.assertIn("proposed_enrollment", serializer.errors)

def test_serializer_outputs_expected_schema_rollout(self):
experiment = ExperimentFactory.create(
type=ExperimentConstants.TYPE_ROLLOUT,
rollout_playbook="Low Risk Schedule",
locales=[self.locale],
countries=[self.country],
population_percent="30.0000",
proposed_enrollment=None,
)

serializer = ExperimentTimelinePopSerializer(experiment)

self.assertEqual(
serializer.data,
{
"proposed_start_date": experiment.proposed_start_date.strftime(
"%Y-%m-%d"
),
"proposed_enrollment": experiment.proposed_enrollment,
"rollout_playbook": experiment.rollout_playbook,
"proposed_duration": experiment.proposed_duration,
"population_percent": experiment.population_percent,
"firefox_channel": experiment.firefox_channel,
"firefox_min_version": experiment.firefox_min_version,
"firefox_max_version": experiment.firefox_max_version,
"locales": [{"value": self.locale.id, "label": self.locale.name}],
"countries": [{"value": self.country.id, "label": self.country.name}],
"platform": experiment.platform,
"client_matching": experiment.client_matching,
},
)

def test_serializer_saves_rollout_playbook_field(self):
experiment = ExperimentFactory.create(
type=ExperimentConstants.TYPE_ROLLOUT,
rollout_playbook="Low Risk Schedule",
locales=[self.locale],
countries=[self.country],
population_percent="30.0000",
proposed_enrollment=None,
)

data = {"rollout_playbook": "High Risk Schedule", "countries": [], "locales": []}

serializer = ExperimentTimelinePopSerializer(
instance=experiment, data=data, context={"request": self.request}
)

self.assertTrue(serializer.is_valid())

experiment = serializer.save()

self.assertEqual(experiment.rollout_playbook, "High Risk Schedule")
Loading

0 comments on commit aabdbb7

Please sign in to comment.