Skip to content
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

Add the approve_addons management command (bug 1199234) #697

Merged
merged 1 commit into from Sep 7, 2015

Conversation

magopian
Copy link
Contributor

Fixes bug 1199234


addons = Addon.with_unlisted.filter(
guid__in=args,
status__in=[amo.STATUS_NOMINATED, amo.STATUS_UNREVIEWED])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add amo.STATUS_PENDING as well, please?

@wagnerand
Copy link
Member

What is the amo_user this script is using?

@wagnerand
Copy link
Member

r+wc

@magopian magopian force-pushed the 1199234-bulk-approval-script branch from 8e07d76 to e60ffd0 Compare August 28, 2015 13:23
@magopian
Copy link
Contributor Author

I updated the PR, thanks @wagnerand. The amo_user is the same used for automatic validations (the "mozilla" user).

@wagnerand
Copy link
Member

Thank you!

# Provide the file to review/sign to the helper.
helper.set_data({'addon_files': [addon.latest_version.files],
'comments': 'bulk approval'})
if addon.status in [amo.STATUS_NOMINATED, amo.STATUS_PENDING]:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to make sure STATUS_PENDING is what we want (cf #700 (comment))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can add STATUS_LITE_AND_NOMINATED, but that is not about pending updates.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, I'm pretty sure there's no specific status for pending updates.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I tracked this down, it should be:

if addon.status in [amo.STATUS_NOMINATED, amo.STATUS_LITE_AND_NOMINATED, amo.STATUS_PUBLIC]:

STATUS_PUBLIC is for pending updates.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense

@magopian
Copy link
Contributor Author

magopian commented Sep 1, 2015

Updated

addons = Addon.with_unlisted.filter(
guid__in=args,
status__in=[amo.STATUS_NOMINATED, amo.STATUS_UNREVIEWED,
amo.STATUS_PENDING])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We ruled out amo.STATUS_PENDING. Let's delete it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, I rewrote it to make it DRYer ;)


FULL_REVIEW_STATUSES = [amo.STATUS_NOMINATED, amo.STATUS_LITE_AND_NOMINATED,
amo.STATUS_PUBLIC]
PRELIM_REVIEW_STATUSES = [amo.STATUS_UNREVIEWED, amo.STATUS_LITE]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move these to constants/base.py?

@kmaglione
Copy link
Contributor

This could really use some tests, but I suppose we can do without them for now. r+wc

@magopian
Copy link
Contributor Author

magopian commented Sep 1, 2015

Updated. Indeed, it would be nice to have tests... I came up with this quick and dirty script that should only be used a couple of time, and only during the "signing transition" (where developers suddenly realize they need to upload all their add-ons to have them signed).

@magopian magopian force-pushed the 1199234-bulk-approval-script branch 2 times, most recently from 8c710e5 to ba3fdf7 Compare September 3, 2015 16:56
@magopian
Copy link
Contributor Author

magopian commented Sep 3, 2015

Completely reworked the code, added tests, I'm not a bit more confident about it ;)

assert file1.reload().status == file_status
assert file2.reload().status == file_status

return (addon, file1, file2, review_type)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This "parametrized pytest fixture" will result in the tests using it to be run once for each "use case". This will result in the following:

screen shot 2015-09-03 at 18 55 42

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, this is not the usual pytest fixture. This is a pytest fixture that uses parametrization. In this case, we're combining the two super-powers of pytest (http://pytest.org/latest/fixture.html#parametrizing-a-fixture), which makes it a bit more hairy than usual.

'comments': 'bulk approval'})
if review_type == 'full':
# Already fully reviewed, or waiting for a full review.
helper.handler.process_public()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does any logging occur in this method? Logging that this was a result of a script would be nice.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, it's all taken care of already, it adds a log stating that it's an approval done by the "mozilla" user, with the comment bulk approval from three lines above

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a test for the presence of those logs

ReviewerScore.award_points(self.request.amo_user, self.addon, status)
if self.request:
ReviewerScore.award_points(self.request.amo_user, self.addon,
status)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are there tests for the skipping of award points?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so, I'll double check

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added, thanks for pointing it out!

@andymckay
Copy link

I think a bit of logging would be good, so we can find out a month or two later exactly how an addon got approved. Other than that lgtm.

@magopian
Copy link
Contributor Author

magopian commented Sep 4, 2015

Added some logging, tests, and chunking, thanks for the review @andymckay, would you mind giving it another look?

Also maybe @wagnerand and @kmaglione ?

@wagnerand
Copy link
Member

lgtm

magopian added a commit that referenced this pull request Sep 7, 2015
Add the approve_addons management command (bug 1199234)
@magopian magopian merged commit 4e51303 into mozilla:master Sep 7, 2015
@magopian magopian deleted the 1199234-bulk-approval-script branch September 7, 2015 13:17
@magopian magopian restored the 1199234-bulk-approval-script branch September 7, 2015 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants