Esempio n. 1
0
    def test_block_duplicate_version(self):
        eq_(self.addon.versions.count(), 1)
        assert tasks.repackage_jetpack(self.builder_data())
        eq_(self.addon.versions.count(), 2)

        # Make a new temp file for urlretrieve.
        tmp_file = self.create_temp_file()
        self.urllib.urlretrieve.return_value = (tmp_file, None)

        assert not tasks.repackage_jetpack(self.builder_data())
        eq_(self.addon.versions.count(), 2)
Esempio n. 2
0
    def test_block_duplicate_version(self):
        eq_(self.addon.versions.count(), 1)
        assert tasks.repackage_jetpack(self.builder_data())
        eq_(self.addon.versions.count(), 2)

        # Make a new temp file for urlretrieve.
        tmp_file = self.create_temp_file()
        self.urllib.urlretrieve.return_value = (tmp_file.name, None)

        assert not tasks.repackage_jetpack(self.builder_data())
        eq_(self.addon.versions.count(), 2)
Esempio n. 3
0
 def test_unreviewed_file_not_on_mirror(self):
     # Make sure the mirror dir is clear.
     mirrordir = settings.MIRROR_STAGE_PATH + "/3615"
     rmtree(mirrordir)
     self.file.update(status=amo.STATUS_UNREVIEWED)
     new_file = tasks.repackage_jetpack(self.builder_data())
     assert not storage.exists(new_file.mirror_file_path)
Esempio n. 4
0
    def test_new_version(self):
        num_versions = self.addon.versions.count()
        new_file = tasks.repackage_jetpack(self.builder_data())
        eq_(num_versions + 1, self.addon.versions.count())

        new_version = self.addon.versions.latest()
        new_version.all_files = [new_file]
Esempio n. 5
0
 def test_unreviewed_file_not_on_mirror(self):
     # Make sure the mirror dir is clear.
     mirrordir = user_media_path('mirror_stage') + '/3615'
     rmtree(mirrordir)
     self.file.update(status=amo.STATUS_UNREVIEWED)
     new_file = tasks.repackage_jetpack(self.builder_data())
     assert not storage.exists(new_file.mirror_file_path)
Esempio n. 6
0
 def test_unreviewed_file_not_on_mirror(self):
     # Make sure the mirror dir is clear.
     mirrordir = settings.MIRROR_STAGE_PATH + '/3615'
     rmtree(mirrordir)
     self.file.update(status=amo.STATUS_UNREVIEWED)
     new_file = tasks.repackage_jetpack(self.builder_data())
     assert not storage.exists(new_file.mirror_file_path)
Esempio n. 7
0
 def test_supported_apps(self):
     version = tasks.repackage_jetpack(self.builder_data()).version
     old_apps = self.file.version.compatible_apps
     eq_(version.compatible_apps.keys(), old_apps.keys())
     for app, appver in version.compatible_apps.items():
         eq_(old_apps[app].max, appver.max)
         eq_(old_apps[app].min, appver.min)
Esempio n. 8
0
    def test_new_version(self):
        num_versions = self.addon.versions.count()
        new_file = tasks.repackage_jetpack(self.builder_data())
        eq_(num_versions + 1, self.addon.versions.count())

        new_version = self.addon.versions.latest()
        new_version.all_files = [new_file]
Esempio n. 9
0
 def test_supported_apps(self):
     version = tasks.repackage_jetpack(self.builder_data()).version
     old_apps = self.file.version.compatible_apps
     eq_(version.compatible_apps.keys(), old_apps.keys())
     for app, appver in version.compatible_apps.items():
         eq_(old_apps[app].max, appver.max)
         eq_(old_apps[app].min, appver.min)
Esempio n. 10
0
    def test_supported_apps(self):
        # Create AppVersions to match what's in the xpi.
        AppVersion.objects.create(application_id=amo.FIREFOX.id, version="3.6")
        AppVersion.objects.create(application_id=amo.FIREFOX.id, version="4.0b6")

        # Make sure the new appver matches the old appver.
        new = tasks.repackage_jetpack(self.builder_data()).version
        for old_app in self.file.version.apps.all():
            new_app = new.apps.filter(application=old_app.application)
            eq_(new_app.values_list("min", "max")[0], (old_app.min_id, old_app.max_id))
Esempio n. 11
0
 def test_cancel_only_affects_bulk(self):
     # Get the data so a row is set in redis.
     data = self.builder_data()
     # Clear out everything.
     self.upgrader.cancel()
     # Put the file back in redis.
     self.upgrader.file(self.file.id, {"uuid": self.uuid, "file": self.file.id, "version": "1.0b4"})
     # Try to clear again, this should skip the ownerless task above.
     self.upgrader.cancel()
     # The task should still work and return a new file.
     assert tasks.repackage_jetpack(data)
Esempio n. 12
0
    def test_supported_apps(self):
        # Create AppVersions to match what's in the xpi.
        AppVersion.objects.create(application=amo.FIREFOX.id, version='3.6')
        AppVersion.objects.create(application=amo.FIREFOX.id, version='4.0b6')

        # Make sure the new appver matches the old appver.
        new = tasks.repackage_jetpack(self.builder_data()).version
        for old_app in self.file.version.apps.all():
            new_app = new.apps.filter(application=old_app.application)
            eq_(
                new_app.values_list('min', 'max')[0],
                (old_app.min_id, old_app.max_id))
Esempio n. 13
0
 def test_cancel_only_affects_bulk(self):
     # Get the data so a row is set in redis.
     data = self.builder_data()
     # Clear out everything.
     self.upgrader.cancel()
     # Put the file back in redis.
     self.upgrader.file(self.file.id, {
         'uuid': self.uuid,
         'version': '1.0b4'
     })
     # Try to clear again, this should skip the ownerless task above.
     self.upgrader.cancel()
     # The task should still work and return a new file.
     assert tasks.repackage_jetpack(data)
Esempio n. 14
0
 def test_new_version_number(self):
     tasks.repackage_jetpack(self.builder_data())
     new_version = self.addon.versions.latest()
     # From jetpack.xpi.
     eq_(new_version.version, '1.3')
Esempio n. 15
0
 def test_unreviewed_file_not_on_mirror(self):
     # Make sure the mirror dir is clear.
     shutil.rmtree(os.path.dirname(self.file.mirror_file_path))
     self.file.update(status=amo.STATUS_UNREVIEWED)
     new_file = tasks.repackage_jetpack(self.builder_data())
     assert not os.path.exists(new_file.mirror_file_path)
Esempio n. 16
0
 def test_unreviewed_file_not_on_mirror(self):
     # Make sure the mirror dir is clear.
     shutil.rmtree(os.path.dirname(self.file.mirror_file_path))
     self.file.update(status=amo.STATUS_UNREVIEWED)
     new_file = tasks.repackage_jetpack(self.builder_data())
     assert not os.path.exists(new_file.mirror_file_path)
Esempio n. 17
0
 def test_file_on_mirror(self):
     # Make sure the mirror dir is clear.
     shutil.rmtree(os.path.dirname(self.file.mirror_file_path))
     new_file = tasks.repackage_jetpack(self.builder_data())
     assert os.path.exists(new_file.mirror_file_path)
Esempio n. 18
0
 def test_result_not_success(self):
     data = self.builder_data(result='fail', msg='oops')
     eq_(tasks.repackage_jetpack(data), None)
Esempio n. 19
0
 def test_result_not_success(self):
     data = self.builder_data(result="fail", msg="oops")
     eq_(tasks.repackage_jetpack(data), None)
Esempio n. 20
0
 def test_new_file_hash(self):
     new_file = tasks.repackage_jetpack(self.builder_data())
     hash_ = hashlib.sha256()
     hash_.update(open(self.xpi_path, 'rb').read())
     eq_(new_file.hash, 'sha256:' + hash_.hexdigest())
Esempio n. 21
0
 def test_bad_addon_id(self):
     data = self.builder_data(addon=22)
     with self.assertRaises(models.ObjectDoesNotExist):
         tasks.repackage_jetpack(data)
Esempio n. 22
0
 def test_bad_file_id(self):
     data = self.builder_data(file_id=234234)
     # Stick the file in the upgrader so it doesn't fail the uuid check.
     self.upgrader.file(234234, {'file': 234234, 'uuid': self.uuid})
     with self.assertRaises(models.ObjectDoesNotExist):
         tasks.repackage_jetpack(data)
Esempio n. 23
0
 def test_result_not_success(self):
     data = self.builder_data(result='fail', msg='oops')
     eq_(tasks.repackage_jetpack(data), None)
Esempio n. 24
0
 def test_bad_file_id(self):
     data = self.builder_data(file_id=234234)
     # Stick the file in the upgrader so it doesn't fail the uuid check.
     self.upgrader.file(234234, {'file': 234234, 'uuid': self.uuid})
     with self.assertRaises(models.ObjectDoesNotExist):
         tasks.repackage_jetpack(data)
Esempio n. 25
0
 def test_new_file_hash(self):
     new_file = tasks.repackage_jetpack(self.builder_data())
     hash_ = hashlib.sha256()
     hash_.update(open(self.xpi_path, 'rb').read())
     eq_(new_file.hash, 'sha256:' + hash_.hexdigest())
Esempio n. 26
0
 def test_urllib_failure(self):
     self.urllib.urlretrieve.side_effect = StopIteration
     with self.assertRaises(StopIteration):
         tasks.repackage_jetpack(self.builder_data())
Esempio n. 27
0
 def test_bad_addon_id(self):
     data = self.builder_data(addon=22)
     with self.assertRaises(models.ObjectDoesNotExist):
         tasks.repackage_jetpack(data)
Esempio n. 28
0
 def test_new_version_number(self):
     tasks.repackage_jetpack(self.builder_data())
     new_version = self.addon.versions.latest()
     # From jetpack.xpi.
     eq_(new_version.version, '1.3')
Esempio n. 29
0
 def test_urllib_failure(self):
     self.urllib.urlretrieve.side_effect = StopIteration
     with self.assertRaises(StopIteration):
         tasks.repackage_jetpack(self.builder_data())
Esempio n. 30
0
 def test_addon_current_version(self):
     new_file = tasks.repackage_jetpack(self.builder_data())
     addon = Addon.objects.get(id=self.addon.id)
     eq_(addon.current_version, new_file.version)
Esempio n. 31
0
 def test_new_file_status(self):
     new_file = tasks.repackage_jetpack(self.builder_data())
     eq_(new_file.status, self.file.status)
Esempio n. 32
0
 def test_clear_redis_after_success(self):
     # Get the data so a row is set in redis.
     data = self.builder_data()
     assert tasks.repackage_jetpack(data)
     eq_(self.upgrader.file(self.file.id), {})
     eq_(self.upgrader.version(), None)
Esempio n. 33
0
 def test_new_file_status(self):
     new_file = tasks.repackage_jetpack(self.builder_data())
     eq_(new_file.status, self.file.status)
Esempio n. 34
0
 def test_addon_current_version(self):
     new_file = tasks.repackage_jetpack(self.builder_data())
     addon = Addon.objects.get(id=self.addon.id)
     eq_(addon.current_version, new_file.version)
Esempio n. 35
0
 def test_cancel(self):
     # Get the data so a row is set in redis.
     data = self.builder_data()
     self.upgrader.cancel()
     eq_(tasks.repackage_jetpack(data), None)
Esempio n. 36
0
 def test_cancel(self):
     # Get the data so a row is set in redis.
     data = self.builder_data()
     self.upgrader.cancel()
     eq_(tasks.repackage_jetpack(data), None)
Esempio n. 37
0
 def test_email_sent(self):
     assert tasks.repackage_jetpack(self.builder_data())
     eq_(len(mail.outbox), 1)
Esempio n. 38
0
 def test_clear_redis_after_success(self):
     # Get the data so a row is set in redis.
     data = self.builder_data()
     assert tasks.repackage_jetpack(data)
     eq_(self.upgrader.file(self.file.id), {})
     eq_(self.upgrader.version(), None)
Esempio n. 39
0
 def test_file_on_mirror(self):
     # Make sure the mirror dir is clear.
     if storage.exists(os.path.dirname(self.file.mirror_file_path)):
         rmtree(os.path.dirname(self.file.mirror_file_path))
     new_file = tasks.repackage_jetpack(self.builder_data())
     assert storage.exists(new_file.mirror_file_path)
Esempio n. 40
0
 def test_email_sent(self):
     assert tasks.repackage_jetpack(self.builder_data())
     eq_(len(mail.outbox), 1)