Пример #1
0
 def test_leave_nondisabled_files(self, os_mock):
     stati = [(mkt.STATUS_PUBLIC, mkt.STATUS_PUBLIC)]
     for addon_status, file_status in stati:
         self.addon.update(status=addon_status)
         File.objects.update(status=file_status)
         cron.hide_disabled_files()
         assert not os_mock.path.exists.called, (addon_status, file_status)
Пример #2
0
 def test_leave_nondisabled_files(self, os_mock):
     stati = [(mkt.STATUS_PUBLIC, mkt.STATUS_PUBLIC)]
     for addon_status, file_status in stati:
         self.addon.update(status=addon_status)
         File.objects.update(status=file_status)
         cron.hide_disabled_files()
         assert not os_mock.path.exists.called, (addon_status, file_status)
Пример #3
0
 def test_move_disabled_file(self, m_storage, mv_mock):
     Webapp.objects.filter(id=self.addon.id).update(
         status=amo.STATUS_REJECTED)
     File.objects.filter(id=self.f1.id).update(status=amo.STATUS_DISABLED)
     cron.hide_disabled_files()
     # f1 should have been moved.
     mv_mock.assert_called_with(self.f1.file_path,
                                self.f1.guarded_file_path, self.msg)
     eq_(mv_mock.call_count, 1)
Пример #4
0
 def test_move_disabled_file(self, m_storage, mv_mock):
     Addon.objects.filter(id=self.addon.id).update(
         status=amo.STATUS_REJECTED)
     File.objects.filter(id=self.f1.id).update(status=amo.STATUS_DISABLED)
     cron.hide_disabled_files()
     # f1 should have been moved.
     mv_mock.assert_called_with(self.f1.file_path,
                                self.f1.guarded_file_path, self.msg)
     eq_(mv_mock.call_count, 1)
Пример #5
0
 def test_ignore_deleted_versions(self, m_storage, mv_mock):
     # Apps only have 1 file and version delete only deletes one.
     self.version.delete()
     mv_mock.reset_mock()
     # Create a new version/file just like the one we deleted.
     version = Version.objects.create(addon=self.addon)
     File.objects.create(version=version, filename='f2')
     cron.hide_disabled_files()
     # Mock shouldn't have been called.
     assert not mv_mock.called, mv_mock.call_args
Пример #6
0
 def test_ignore_deleted_versions(self, m_storage, mv_mock):
     # Apps only have 1 file and version delete only deletes one.
     self.version.delete()
     mv_mock.reset_mock()
     # Create a new version/file just like the one we deleted.
     version = Version.objects.create(addon=self.addon)
     File.objects.create(version=version, filename='f2')
     cron.hide_disabled_files()
     # Mock shouldn't have been called.
     assert not mv_mock.called, mv_mock.call_args
Пример #7
0
 def test_move_admin_disabled_addon(self, m_storage, mv_mock):
     Addon.objects.filter(id=self.addon.id).update(
         status=amo.STATUS_DISABLED)
     File.objects.update(status=amo.STATUS_PUBLIC)
     cron.hide_disabled_files()
     # Check that f1 was moved.
     mv_mock.assert_called_with(self.f1.file_path,
                                self.f1.guarded_file_path, self.msg)
     # There's only 1 file.
     eq_(mv_mock.call_count, 1)
Пример #8
0
 def test_move_admin_disabled_addon(self, m_storage, mv_mock):
     Webapp.objects.filter(id=self.addon.id).update(
         status=amo.STATUS_DISABLED)
     File.objects.update(status=amo.STATUS_PUBLIC)
     cron.hide_disabled_files()
     # Check that f1 was moved.
     mv_mock.assert_called_with(self.f1.file_path,
                                self.f1.guarded_file_path, self.msg)
     # There's only 1 file.
     eq_(mv_mock.call_count, 1)
Пример #9
0
 def test_move_disabled_file(self, m_storage, mv_mock):
     Webapp.objects.filter(id=self.webapp.id).update(
         status=mkt.STATUS_REJECTED)
     File.objects.filter(id=self.f1.id).update(status=mkt.STATUS_DISABLED)
     cron.hide_disabled_files()
     # f1 should have been moved.
     mv_mock.assert_called_with(self.f1.file_path,
                                self.f1.guarded_file_path, self.msg,
                                src_storage=public_storage,
                                dst_storage=m_storage)
     eq_(mv_mock.call_count, 1)
Пример #10
0
    def test_move_user_disabled_addon(self, m_storage, mv_mock):
        # Use Addon.objects.update so the signal handler isn't called.
        Addon.objects.filter(id=self.addon.id).update(
            status=amo.STATUS_PUBLIC, disabled_by_user=True)
        File.objects.update(status=amo.STATUS_PUBLIC)
        cron.hide_disabled_files()

        # Check that f1 was moved.
        mv_mock.assert_called_with(self.f1.file_path,
                                   self.f1.guarded_file_path, self.msg)
        # There's only 1 file.
        eq_(mv_mock.call_count, 1)
Пример #11
0
 def test_move_admin_disabled_webapp(self, m_storage, mv_mock):
     Webapp.objects.filter(id=self.webapp.id).update(
         status=mkt.STATUS_DISABLED)
     File.objects.update(status=mkt.STATUS_PUBLIC)
     cron.hide_disabled_files()
     # Check that f1 was moved.
     mv_mock.assert_called_with(self.f1.file_path,
                                self.f1.guarded_file_path, self.msg,
                                src_storage=m_storage,
                                dst_storage=private_storage)
     # There's only 1 file.
     eq_(mv_mock.call_count, 1)
Пример #12
0
    def test_move_user_disabled_addon(self, m_storage, mv_mock):
        # Use Webapp.objects.update so the signal handler isn't called.
        Webapp.objects.filter(id=self.addon.id).update(
            status=amo.STATUS_PUBLIC, disabled_by_user=True)
        File.objects.update(status=amo.STATUS_PUBLIC)
        cron.hide_disabled_files()

        # Check that f1 was moved.
        mv_mock.assert_called_with(self.f1.file_path,
                                   self.f1.guarded_file_path, self.msg)
        # There's only 1 file.
        eq_(mv_mock.call_count, 1)
Пример #13
0
    def test_move_user_disabled_webapp(self, m_storage, mv_mock):
        # Use Webapp.objects.update so the signal handler isn't called.
        Webapp.objects.filter(id=self.webapp.id).update(
            status=mkt.STATUS_PUBLIC, disabled_by_user=True)
        File.objects.update(status=mkt.STATUS_PUBLIC)
        cron.hide_disabled_files()

        # Check that f1 was moved.
        mv_mock.assert_called_with(self.f1.file_path,
                                   self.f1.guarded_file_path, self.msg,
                                   src_storage=m_storage,
                                   dst_storage=private_storage)
        # There's only 1 file.
        eq_(mv_mock.call_count, 1)