Skip to content

Commit

Permalink
[Backend] Add worker instance type to serializer (#4186)
Browse files Browse the repository at this point in the history
  • Loading branch information
gchhablani authored Oct 4, 2023
1 parent 730737f commit 42f780e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
3 changes: 2 additions & 1 deletion apps/challenges/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ class Meta:
"uses_ec2_worker",
"ec2_storage",
"evaluation_module_error",
"worker_image_url"
"worker_image_url",
"worker_instance_type"
)


Expand Down
19 changes: 19 additions & 0 deletions tests/unit/challenges/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ def test_get_challenge(self):
"evaluation_module_error": self.challenge.evaluation_module_error,
"ec2_storage": self.challenge.ec2_storage,
"worker_image_url": self.challenge.worker_image_url,
"worker_instance_type": self.challenge.worker_instance_type,
}
]

Expand Down Expand Up @@ -544,6 +545,7 @@ def test_get_particular_challenge(self):
"evaluation_module_error": self.challenge.evaluation_module_error,
"ec2_storage": self.challenge.ec2_storage,
"worker_image_url": self.challenge.worker_image_url,
"worker_instance_type": self.challenge.worker_instance_type,
}
response = self.client.get(self.url, {})
self.assertEqual(response.data, expected)
Expand Down Expand Up @@ -643,6 +645,7 @@ def test_update_challenge_when_user_is_its_creator(self):
"evaluation_module_error": self.challenge.evaluation_module_error,
"ec2_storage": self.challenge.ec2_storage,
"worker_image_url": self.challenge.worker_image_url,
"worker_instance_type": self.challenge.worker_instance_type,
}
response = self.client.put(
self.url, {"title": new_title, "description": new_description}
Expand Down Expand Up @@ -768,6 +771,7 @@ def test_particular_challenge_partial_update(self):
"evaluation_module_error": self.challenge.evaluation_module_error,
"ec2_storage": self.challenge.ec2_storage,
"worker_image_url": self.challenge.worker_image_url,
"worker_instance_type": self.challenge.worker_instance_type,
}
response = self.client.patch(self.url, self.partial_update_data)
self.assertEqual(response.data, expected)
Expand Down Expand Up @@ -842,6 +846,7 @@ def test_particular_challenge_update(self):
"evaluation_module_error": self.challenge.evaluation_module_error,
"ec2_storage": self.challenge.ec2_storage,
"worker_image_url": self.challenge.worker_image_url,
"worker_instance_type": self.challenge.worker_instance_type,
}
response = self.client.put(self.url, self.data)
self.assertEqual(response.data, expected)
Expand Down Expand Up @@ -1432,6 +1437,7 @@ def test_get_past_challenges(self):
"evaluation_module_error": self.challenge3.evaluation_module_error,
"ec2_storage": self.challenge3.ec2_storage,
"worker_image_url": self.challenge3.worker_image_url,
"worker_instance_type": self.challenge3.worker_instance_type,
}
]
response = self.client.get(self.url, {}, format="json")
Expand Down Expand Up @@ -1512,6 +1518,7 @@ def test_get_present_challenges(self):
"evaluation_module_error": self.challenge2.evaluation_module_error,
"ec2_storage": self.challenge.ec2_storage,
"worker_image_url": self.challenge.worker_image_url,
"worker_instance_type": self.challenge.worker_instance_type,
}
]
response = self.client.get(self.url, {}, format="json")
Expand Down Expand Up @@ -1592,6 +1599,7 @@ def test_get_future_challenges(self):
"evaluation_module_error": self.challenge4.evaluation_module_error,
"ec2_storage": self.challenge4.ec2_storage,
"worker_image_url": self.challenge4.worker_image_url,
"worker_instance_type": self.challenge4.worker_instance_type,
}
]
response = self.client.get(self.url, {}, format="json")
Expand Down Expand Up @@ -1672,6 +1680,7 @@ def test_get_all_challenges(self):
"evaluation_module_error": self.challenge3.evaluation_module_error,
"ec2_storage": self.challenge3.ec2_storage,
"worker_image_url": self.challenge3.worker_image_url,
"worker_instance_type": self.challenge3.worker_instance_type,
},
{
"id": self.challenge3.pk,
Expand Down Expand Up @@ -1736,6 +1745,7 @@ def test_get_all_challenges(self):
"evaluation_module_error": self.challenge3.evaluation_module_error,
"ec2_storage": self.challenge3.ec2_storage,
"worker_image_url": self.challenge3.worker_image_url,
"worker_instance_type": self.challenge3.worker_instance_type,
},
{
"id": self.challenge2.pk,
Expand Down Expand Up @@ -1800,6 +1810,7 @@ def test_get_all_challenges(self):
"evaluation_module_error": self.challenge2.evaluation_module_error,
"ec2_storage": self.challenge2.ec2_storage,
"worker_image_url": self.challenge2.worker_image_url,
"worker_instance_type": self.challenge2.worker_instance_type,
},
]
response = self.client.get(self.url, {}, format="json")
Expand Down Expand Up @@ -1935,6 +1946,7 @@ def test_get_featured_challenges(self):
"evaluation_module_error": self.challenge3.evaluation_module_error,
"ec2_storage": self.challenge3.ec2_storage,
"worker_image_url": self.challenge3.worker_image_url,
"worker_instance_type": self.challenge3.worker_instance_type,
}
]
response = self.client.get(self.url, {}, format="json")
Expand Down Expand Up @@ -2094,6 +2106,7 @@ def test_get_challenge_by_pk_when_user_is_challenge_host(self):
"evaluation_module_error": self.challenge3.evaluation_module_error,
"ec2_storage": self.challenge3.ec2_storage,
"worker_image_url": self.challenge3.worker_image_url,
"worker_instance_type": self.challenge3.worker_instance_type,
}

response = self.client.get(self.url, {})
Expand Down Expand Up @@ -2182,6 +2195,7 @@ def test_get_challenge_by_pk_when_user_is_participant(self):
"evaluation_module_error": self.challenge4.evaluation_module_error,
"ec2_storage": self.challenge4.ec2_storage,
"worker_image_url": self.challenge4.worker_image_url,
"worker_instance_type": self.challenge4.worker_instance_type,
}

self.client.force_authenticate(user=self.user1)
Expand Down Expand Up @@ -2330,6 +2344,7 @@ def test_get_challenge_when_host_team_is_given(self):
"evaluation_module_error": self.challenge2.evaluation_module_error,
"ec2_storage": self.challenge2.ec2_storage,
"worker_image_url": self.challenge2.worker_image_url,
"worker_instance_type": self.challenge2.worker_instance_type,
}
]

Expand Down Expand Up @@ -2406,6 +2421,7 @@ def test_get_challenge_when_participant_team_is_given(self):
"evaluation_module_error": self.challenge2.evaluation_module_error,
"ec2_storage": self.challenge2.ec2_storage,
"worker_image_url": self.challenge2.worker_image_url,
"worker_instance_type": self.challenge2.worker_instance_type,
}
]

Expand Down Expand Up @@ -2482,6 +2498,7 @@ def test_get_challenge_when_mode_is_participant(self):
"evaluation_module_error": self.challenge2.evaluation_module_error,
"ec2_storage": self.challenge2.ec2_storage,
"worker_image_url": self.challenge2.worker_image_url,
"worker_instance_type": self.challenge2.worker_instance_type,
}
]

Expand Down Expand Up @@ -2556,6 +2573,7 @@ def test_get_challenge_when_mode_is_host(self):
"evaluation_module_error": self.challenge.evaluation_module_error,
"ec2_storage": self.challenge.ec2_storage,
"worker_image_url": self.challenge.worker_image_url,
"worker_instance_type": self.challenge.worker_instance_type,
},
{
"id": self.challenge2.pk,
Expand Down Expand Up @@ -2620,6 +2638,7 @@ def test_get_challenge_when_mode_is_host(self):
"evaluation_module_error": self.challenge2.evaluation_module_error,
"ec2_storage": self.challenge2.ec2_storage,
"worker_image_url": self.challenge2.worker_image_url,
"worker_instance_type": self.challenge2.worker_instance_type,
},
]

Expand Down
2 changes: 2 additions & 0 deletions tests/unit/participants/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,7 @@ def test_get_teams_and_corresponding_challenges_for_a_participant(self):
"ec2_storage": self.challenge1.ec2_storage,
"evaluation_module_error": self.challenge1.evaluation_module_error,
"worker_image_url": self.challenge1.worker_image_url,
"worker_instance_type": self.challenge1.worker_instance_type,
},
"participant_team": {
"id": self.participant_team.id,
Expand Down Expand Up @@ -972,6 +973,7 @@ def test_get_participant_team_challenge_list(self):
"ec2_storage": self.challenge1.ec2_storage,
"evaluation_module_error": self.challenge1.evaluation_module_error,
"worker_image_url": self.challenge1.worker_image_url,
"worker_instance_type": self.challenge1.worker_instance_type,
}
]

Expand Down

0 comments on commit 42f780e

Please sign in to comment.