def test_approve(self, review_helper_mock): command = auto_approve.Command() command.approve(self.version) assert review_helper_mock.call_count == 1 assert review_helper_mock.call_args == ( (), {'addon': self.addon, 'version': self.version} ) assert review_helper_mock().handler.process_public.call_count == 1
def test_fetch_candidates(self): # Add a bunch of add-ons in various states that should not be returned. # Public add-on with no updates. addon_factory(file_kw={'is_webextension': True}) # Non-extension with updates. search_addon = addon_factory(type=amo.ADDON_SEARCH) version_factory(addon=search_addon, file_kw={ 'status': amo.STATUS_AWAITING_REVIEW, 'is_webextension': True}) # Disabled add-on with updates. disabled_addon = addon_factory(disabled_by_user=True) version_factory(addon=disabled_addon, file_kw={ 'status': amo.STATUS_AWAITING_REVIEW, 'is_webextension': True}) # Non-public add-on addon_factory(status=amo.STATUS_NOMINATED, file_kw={ 'status': amo.STATUS_AWAITING_REVIEW, 'is_webextension': True}) # Add-on with deleted version. addon_with_deleted_version = addon_factory() deleted_version = version_factory( addon=addon_with_deleted_version, file_kw={ 'status': amo.STATUS_AWAITING_REVIEW, 'is_webextension': True}) deleted_version.delete() # Add-on with a non-webextension update. non_webext_addon = addon_factory() version_factory(addon=non_webext_addon, file_kw={ 'status': amo.STATUS_AWAITING_REVIEW}) # Add-on with 3 versions: # - one webext, listed, public. # - one non-listed webext version # - one listed non-webext awaiting review. complex_addon = addon_factory(file_kw={'is_webextension': True}) version_factory( addon=complex_addon, channel=amo.RELEASE_CHANNEL_UNLISTED, file_kw={'is_webextension': True}) version_factory(addon=complex_addon, file_kw={ 'status': amo.STATUS_AWAITING_REVIEW}) # Finally, add a second file to self.version to test the distinct(). file_factory( version=self.version, status=amo.STATUS_AWAITING_REVIEW, is_webextension=True) # Gather the candidates. command = auto_approve.Command() qs = command.fetch_candidates() # Only self.version should be found, once. assert len(qs) == 1 assert qs[0] == self.version
def test_fetch_candidates(self): # Add nominated add-on: it should be considered. self.version.update(nomination=self.days_ago(1)) new_addon = addon_factory(status=amo.STATUS_NOMINATED, file_kw={ 'status': amo.STATUS_AWAITING_REVIEW, 'is_webextension': True }) new_addon_version = new_addon.versions.all()[0] new_addon_version.update(nomination=self.days_ago(2)) # Add langpack: it should also be considered. langpack = addon_factory(type=amo.ADDON_LPAPP, status=amo.STATUS_NOMINATED, file_kw={ 'status': amo.STATUS_AWAITING_REVIEW, 'is_webextension': True }) langpack_version = langpack.versions.all()[0] langpack_version.update(nomination=self.days_ago(3)) # Add a bunch of add-ons in various states that should not be returned. # Public add-on with no updates. addon_factory(file_kw={'is_webextension': True}) # Non-extension with updates. search_addon = addon_factory(type=amo.ADDON_SEARCH) version_factory(addon=search_addon, file_kw={ 'status': amo.STATUS_AWAITING_REVIEW, 'is_webextension': True }) # Disabled add-on with updates. disabled_addon = addon_factory(disabled_by_user=True) version_factory(addon=disabled_addon, file_kw={ 'status': amo.STATUS_AWAITING_REVIEW, 'is_webextension': True }) # Add-on with deleted version. addon_with_deleted_version = addon_factory() deleted_version = version_factory(addon=addon_with_deleted_version, file_kw={ 'status': amo.STATUS_AWAITING_REVIEW, 'is_webextension': True }) deleted_version.delete() # Add-on with a non-webextension update. non_webext_addon = addon_factory() version_factory(addon=non_webext_addon, file_kw={'status': amo.STATUS_AWAITING_REVIEW}) # Add-on with 3 versions: # - one webext, listed, public. # - one non-listed webext version # - one listed non-webext awaiting review. complex_addon = addon_factory(file_kw={'is_webextension': True}) version_factory(addon=complex_addon, channel=amo.RELEASE_CHANNEL_UNLISTED, file_kw={'is_webextension': True}) version_factory(addon=complex_addon, file_kw={'status': amo.STATUS_AWAITING_REVIEW}) # Finally, add a second file to self.version to test the distinct(). file_factory(version=self.version, status=amo.STATUS_AWAITING_REVIEW, is_webextension=True) # Gather the candidates. command = auto_approve.Command() command.post_review = True qs = command.fetch_candidates() # 3 versions should be found. Because of the nomination date, # langpack_version should be first (its nomination date is the oldest), # followed by new_addon_version and then self.version. assert len(qs) == 3 assert qs[0] == langpack_version assert qs[1] == new_addon_version assert qs[2] == self.version