-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
feat(crons): Add monitor slug to APIs #45294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(crons): Add monitor slug to APIs #45294
Conversation
evanpurkhiser
commented
Mar 2, 2023
- Returns slug as part of the serialized monitor
- Allows slug to be specified for creation and updates
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #45294 +/- ##
===========================================
+ Coverage 57.10% 80.22% +23.12%
===========================================
Files 4689 4724 +35
Lines 198189 198819 +630
Branches 12006 12007 +1
===========================================
+ Hits 113173 159504 +46331
+ Misses 84754 39053 -45701
Partials 262 262
|
| class MonitorValidator(serializers.Serializer): | ||
| project = ProjectField(scope="project:read") | ||
| name = serializers.CharField() | ||
| slug = serializers.RegexField(r"^[a-z0-9_\-]+$", max_length=50, required=False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ideally we could move this to a shared constant but probably outside the scope of this PR. just like a ALPHANUMERIC_SLUG_REGEX
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's used in 4 other places
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a lot of inconsistent slug = serializer.RegexField
| monitor = Monitor.objects.get(id=monitor.id) | ||
| assert monitor.name == "Monitor Name" | ||
|
|
||
| def test_slug(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
worth adding a test where slug is specified but is None or "", I don't think the regex checker will allow it in MonitorValidator. generally we allow None values as equivalent to not specifying an optional param
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated. It fails with 'cannot be blank'
139170b to
f13048e
Compare
f13048e to
69481a9
Compare
69481a9 to
535f4a2
Compare
535f4a2 to
3463d50
Compare
* Returns slug as part of the serialized monitor * Allows slug to be specified for creation and updates
3463d50 to
93b2f82
Compare