def test_fix_let_scope_bustage_in_addon(mock_sign_file, mock_version_bump, mock_fixer, db): # Create an add-on, with a version. addon = amo.tests.addon_factory() addon.update(guid="xxxxx") # Add another version, which is the one we want to fix. version = Version.objects.create(addon=addon, version="0.1") # So addon.versions.first() (which is the last one uploaded) works. future_date = datetime.now() + timedelta(days=1) version.update(created=future_date) assert addon.versions.count() == 2 # Two versions, we only fix the last. # Assign a file for the last version's file. test_xpi = "apps/files/fixtures/files/extension-let-global-scope.xpi" file_ = File.objects.create(version=version, filename="foo.xpi", is_signed=True) with override_settings(PRELIMINARY_SIGNING_SERVER="prelim_signing"): with amo.tests.copy_file(test_xpi, file_.file_path): # Fix the file! tasks.fix_let_scope_bustage_in_addons([addon.pk]) # fix_let_scope_bustage_in_xpi was called. mock_fixer.assert_called_once_with(file_.file_path) # Version was bumped. bumped_version_number = u"0.1.1-let-fixed" version.reload().version == bumped_version_number mock_version_bump.assert_called_once_with(file_, bumped_version_number) # File was signed. mock_sign_file.assert_called_once_with(file_, "prelim_signing")
def handle(self, *args, **options): if len(args) == 0: raise CommandError('Please provide at least one add-on id to fix.') addon_ids = [int(addon_id) for addon_id in args] fix_let_scope_bustage_in_addons(addon_ids)