-
Notifications
You must be signed in to change notification settings - Fork 149
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
a fix for duplicate alias problem #3010
Changes from 21 commits
cf2ce74
b78811e
9f9b6df
8f5f13b
9cc67e2
8c5eaec
450e1ae
e3ed332
898c330
59bc8a3
e3fb94c
5ce07b4
2254047
c870770
7fa4c05
399ee9a
9051216
2ca2d73
167b56a
0f6f3cb
c46d589
aef0681
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2238,6 +2238,146 @@ def testAddScheduledChangeMultipleConditions(self): | |
ret = self._post("scheduled_changes/rules", data=data) | ||
self.assertEqual(ret.status_code, 400) | ||
|
||
@mock.patch("time.time", mock.MagicMock(return_value=300)) | ||
def testAddScheduledChangesRuleWithDuplicateAliasWithChangeTypeInsert(self): | ||
ret = self._post( | ||
"/rules", | ||
data=dict(backgroundRate=31, mapping="c", priority=33, product="Firefox", update_type="minor", channel="nightly", alias="TestDuplicateAlias1"), | ||
) | ||
self.assertEqual(ret.status_code, 200, "Status Code: %d, Data: %s" % (ret.status_code, ret.get_data())) | ||
|
||
data1 = { | ||
"rule_id": 10, | ||
"telemetry_product": None, | ||
"telemetry_channel": None, | ||
"telemetry_uptake": None, | ||
"priority": 80, | ||
"buildTarget": "d", | ||
"version": "3.3", | ||
"backgroundRate": 100, | ||
"mapping": "c", | ||
"update_type": "minor", | ||
"data_version": 1, | ||
"change_type": "insert", | ||
"when": 1234567, | ||
"base_alias": "TestDuplicateAlias1", | ||
} | ||
ret1 = self._post("/scheduled_changes/rules", data=data1) | ||
godplayer56 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
self.assertEqual(ret1.status_code, 400, ret1.get_data()) | ||
load = ret1.get_json() | ||
self.assertEqual(load["detail"], "Rule with alias exists") | ||
|
||
@mock.patch("time.time", mock.MagicMock(return_value=300)) | ||
def testAddScheduledChangesRuleWithDuplicateAliasWithChangeTypeUpdate(self): | ||
ret = self._post( | ||
"/rules", | ||
data=dict(backgroundRate=31, mapping="c", priority=33, product="Firefox", update_type="minor", channel="nightly", alias="TestDuplicateAlias2"), | ||
) | ||
self.assertEqual(ret.status_code, 200, "Status Code: %d, Data: %s" % (ret.status_code, ret.get_data())) | ||
|
||
data1 = { | ||
"rule_id": 10, | ||
"telemetry_product": None, | ||
"telemetry_channel": None, | ||
"telemetry_uptake": None, | ||
"priority": 80, | ||
"buildTarget": "d", | ||
"version": "3.3", | ||
"backgroundRate": 100, | ||
"mapping": "c", | ||
"update_type": "minor", | ||
"data_version": 1, | ||
"change_type": "update", | ||
"when": 1234567, | ||
"base_alias": "TestDuplicateAlias2", | ||
} | ||
ret1 = self._post("/scheduled_changes/rules", data=data1) | ||
self.assertEqual(ret1.status_code, 400, ret1.get_data()) | ||
load = ret1.get_json() | ||
self.assertEqual(load["detail"], "Rule with alias exists") | ||
|
||
@mock.patch("time.time", mock.MagicMock(return_value=300)) | ||
def testAddScheduledChangeWithAliasAlreadyPresentWithChangeTypeInsert(self): | ||
data = { | ||
"rule_id": 5, | ||
"telemetry_product": None, | ||
"telemetry_channel": None, | ||
"telemetry_uptake": None, | ||
"priority": 80, | ||
"buildTarget": "d", | ||
"version": "3.3", | ||
"backgroundRate": 100, | ||
"mapping": "c", | ||
"update_type": "minor", | ||
"data_version": 1, | ||
"change_type": "insert", | ||
"when": 1234567, | ||
"base_alias": "TestDuplicateAlias3", | ||
"complete": False, | ||
} | ||
ret = self._post("/scheduled_changes/rules", data=data) | ||
self.assertEqual(ret.status_code, 200, ret.get_data()) | ||
|
||
data1 = { | ||
"when": 2000000, | ||
"data_version": 1, | ||
"rule_id": 1, | ||
"priority": 100, | ||
"version": "3.5", | ||
"buildTarget": "d", | ||
"backgroundRate": 100, | ||
"mapping": "c", | ||
"update_type": "minor", | ||
"sc_data_version": 1, | ||
"base_alias": "TestDuplicateAlias3", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also try simulating a request like this on https://localhost:9000/rules/364 by adding an alias and clicking the Save button - take a dlook at what the the Request JSON looks like in the Developer Tools. If it doesn't use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I got base_alias from the scheduledChangesTable because in some instances it referred to base_alias instead of alias 😅 . Can you provide me with authorization so I can see what a post request looks like? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have updated all the files to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should be fully authorized in your local development environment... In any case, I can assure you that the admin API doesn't use |
||
"complete": False, | ||
} | ||
ret1 = self._post("/scheduled_changes/rules/4", data=data1) | ||
self.assertEqual(ret1.status_code, 400, ret1.get_data()) | ||
load = ret1.get_json() | ||
self.assertEqual(load["detail"], "Rule is scheduled with the given alias") | ||
|
||
@mock.patch("time.time", mock.MagicMock(return_value=300)) | ||
def testAddScheduledChangeWithAliasAlreadyPresentWithChangeTypeUpdate(self): | ||
data = { | ||
"rule_id": 5, | ||
"telemetry_product": None, | ||
"telemetry_channel": None, | ||
"telemetry_uptake": None, | ||
"priority": 80, | ||
"buildTarget": "d", | ||
"version": "3.3", | ||
"backgroundRate": 100, | ||
"mapping": "c", | ||
"update_type": "minor", | ||
"data_version": 1, | ||
"change_type": "update", | ||
"when": 1234567, | ||
"base_alias": "TestDuplicateAlias4", | ||
"complete": False, | ||
} | ||
ret = self._post("/scheduled_changes/rules", data=data) | ||
self.assertEqual(ret.status_code, 200, ret.get_data()) | ||
|
||
data1 = { | ||
"when": 2000000, | ||
"data_version": 1, | ||
"rule_id": 1, | ||
"priority": 100, | ||
"version": "3.5", | ||
"buildTarget": "d", | ||
"backgroundRate": 100, | ||
"mapping": "c", | ||
"update_type": "minor", | ||
"sc_data_version": 1, | ||
"base_alias": "TestDuplicateAlias4", | ||
"complete": False, | ||
} | ||
ret1 = self._post("/scheduled_changes/rules/4", data=data1) | ||
self.assertEqual(ret1.status_code, 400, ret1.get_data()) | ||
load = ret1.get_json() | ||
self.assertEqual(load["detail"], "Rule is scheduled with the given alias") | ||
|
||
def testAddScheduledChangeMissingRequiredTelemetryFields(self): | ||
data = {"telemetry_product": "foo", "priority": 120, "backgroundRate": 100, "update_type": "minor", "change_type": "insert"} | ||
ret = self._post("scheduled_changes/rules", data=data) | ||
|
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.
I think the problem is that in this part of the view this needs to be referred to as
alias
(notbase_alias
). I suggest you try printing outwhat
and making a web request to confirm this.