当前位置: 首页>>代码示例>>Python>>正文


Python models.Extension类代码示例

本文整理汇总了Python中mkt.extensions.models.Extension的典型用法代码示例。如果您正苦于以下问题:Python Extension类的具体用法?Python Extension怎么用?Python Extension使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Extension类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_is_public

    def test_is_public(self):
        extension = Extension(disabled=False, status=STATUS_PUBLIC)
        eq_(extension.is_public(), True)

        for status in (STATUS_NULL, STATUS_PENDING):
            extension.status = status
            eq_(extension.is_public(), False)
开发者ID:,项目名称:,代码行数:7,代码来源:

示例2: fake_object

    def fake_object(self, data):
        """Create a fake instance of Extension from ES data."""
        obj = Extension(id=data['id'])

        # Create a fake ExtensionVersion for latest_public_version.
        obj.latest_public_version = ExtensionVersion(
            extension=obj,
            pk=data['latest_public_version']['id'],
            size=data['latest_public_version'].get('size', 0),
            status=STATUS_PUBLIC,
            version=data['latest_public_version']['version'],)

        # Set basic attributes we'll need on the fake instance using the data
        # from ES.
        self._attach_fields(
            obj, data, ('default_language', 'last_updated', 'slug', 'status',
                        'version'))

        obj.disabled = data['is_disabled']
        obj.uuid = data['guid']

        # Attach translations for all translated attributes.
        # obj.default_language should be set first for this to work.
        self._attach_translations(
            obj, data, ('name', 'description', ))

        # Some methods might need the raw data from ES, put it on obj.
        obj.es_data = data

        return obj
开发者ID:,项目名称:,代码行数:30,代码来源:

示例3: test_remove_signed_file_not_exists

 def test_remove_signed_file_not_exists(self, public_storage_mock):
     extension = Extension(pk=42, slug='mocked_ext')
     public_storage_mock.exists.return_value = False
     extension.remove_signed_file()
     eq_(public_storage_mock.exists.call_args[0][0],
         extension.signed_file_path)
     eq_(public_storage_mock.delete.call_count, 0)
开发者ID:shahbaz17,项目名称:zamboni,代码行数:7,代码来源:test_models.py

示例4: fake_object

    def fake_object(self, data):
        """Create a fake instance of Extension from ES data."""
        obj = Extension(id=data["id"])

        # Create a fake ExtensionVersion for latest_public_version.
        obj.latest_public_version = ExtensionVersion(
            extension=obj,
            pk=data["latest_public_version"]["id"],
            status=STATUS_PUBLIC,
            version=data["latest_public_version"]["version"],
        )

        # Set basic attributes we'll need on the fake instance using the data
        # from ES.
        self._attach_fields(obj, data, ("default_language", "slug", "status", "version"))

        obj.uuid = data["guid"]

        # Attach translations for all translated attributes.
        # obj.default_language should be set first for this to work.
        self._attach_translations(obj, data, ("name", "description"))

        # Some methods might need the raw data from ES, put it on obj.
        obj.es_data = data

        return obj
开发者ID:demagu-sr,项目名称:zamboni,代码行数:26,代码来源:serializers.py

示例5: test_sign_and_move_file_error

 def test_sign_and_move_file_error(self, remove_signed_file_mock,
                                   private_storage_mock, sign_app_mock):
     extension = Extension(uuid='12345678123456781234567812345678')
     sign_app_mock.side_effect = SigningError
     with self.assertRaises(SigningError):
         extension.sign_and_move_file()
     eq_(remove_signed_file_mock.call_count, 1)
开发者ID:shahbaz17,项目名称:zamboni,代码行数:7,代码来源:test_models.py

示例6: test_remove_signed_file

 def test_remove_signed_file(self, mocked_public_storage):
     extension = Extension(pk=42, slug='mocked_ext')
     mocked_public_storage.exists.return_value = True
     extension.remove_signed_file()
     eq_(mocked_public_storage.exists.call_args[0][0],
         extension.signed_file_path)
     eq_(mocked_public_storage.delete.call_args[0][0],
         extension.signed_file_path)
开发者ID:shahbaz17,项目名称:zamboni,代码行数:8,代码来源:test_models.py

示例7: test_mini_manifest

    def test_mini_manifest(self):
        manifest = {'foo': {'bar': 1}}
        extension = Extension(pk=44, version='0.44.0', manifest=manifest,
                              uuid='abcdefabcdefabcdefabcdefabcdef12')
        expected_manifest = {
            'foo': {'bar': 1},
            'package_path': extension.download_url,
        }
        eq_(extension.mini_manifest, expected_manifest)

        # Make sure that mini_manifest is a deepcopy.
        extension.mini_manifest['foo']['bar'] = 42
        eq_(extension.manifest['foo']['bar'], 1)
开发者ID:tsl143,项目名称:zamboni,代码行数:13,代码来源:test_models.py

示例8: test_sign_and_move_file

 def test_sign_and_move_file(self, remove_signed_file_mock,
                             private_storage_mock, sign_app_mock):
     extension = Extension(uuid='12345678123456781234567812345678')
     extension.sign_and_move_file()
     expected_args = (
         private_storage_mock.open.return_value,
         extension.signed_file_path,
         json.dumps({
             'id': extension.uuid,
             'version': 1
         })
     )
     eq_(sign_app_mock.call_args[0], expected_args)
     eq_(remove_signed_file_mock.call_count, 0)
开发者ID:shahbaz17,项目名称:zamboni,代码行数:14,代码来源:test_models.py

示例9: tearDown

    def tearDown(self):
        for o in Webapp.objects.all():
            o.delete()
        for o in Extension.objects.all():
            o.delete()
        super(TestMultiSearchView, self).tearDown()

        # Make sure to delete and unindex *all* things. Normally we wouldn't
        # care about stray deleted content staying in the index, but they can
        # have an impact on relevancy scoring so we need to make sure. This
        # needs to happen after super() has been called since it'll process the
        # indexing tasks that should happen post_request, and we need to wait
        # for ES to have done everything before continuing.
        Webapp.get_indexer().unindexer(_all=True)
        Extension.get_indexer().unindexer(_all=True)
        HomescreenIndexer.unindexer(_all=True)
        self.refresh(('webapp', 'extension', 'homescreen'))
开发者ID:digideskio,项目名称:zamboni,代码行数:17,代码来源:test_views.py

示例10: fake_object

    def fake_object(self, data):
        """Create a fake instance of Extension from ES data."""
        obj = Extension(id=data['id'])

        # Set basic attributes we'll need on the fake instance using the data
        # from ES.
        self._attach_fields(
            obj, data, ('default_language', 'slug', 'status', 'version'))

        obj.uuid = data['guid']

        # Attach translations for all translated attributes.
        # obj.default_language should be set first for this to work.
        self._attach_translations(
            obj, data, ('name', ))

        # Some methods might need the raw data from ES, put it on obj.
        obj.es_data = data

        return obj
开发者ID:tsl143,项目名称:zamboni,代码行数:20,代码来源:serializers.py

示例11: test_upload_new

 def test_upload_new(self):
     eq_(Extension.objects.count(), 0)
     upload = self.upload('extension')
     extension = Extension.from_upload(upload, user=self.user)
     eq_(extension.version, '0.1')
     eq_(list(extension.authors.all()), [self.user])
     eq_(extension.name, u'My Lîttle Extension')
     eq_(extension.default_language, 'en-GB')
     eq_(extension.slug, u'my-lîttle-extension')
     eq_(extension.filename, 'extension-%s.zip' % extension.version)
     ok_(extension.filename in extension.file_path)
     ok_(private_storage.exists(extension.file_path))
     eq_(extension.manifest, self.expected_manifest)
     eq_(Extension.objects.count(), 1)
开发者ID:shahbaz17,项目名称:zamboni,代码行数:14,代码来源:test_models.py

示例12: test_upload_new

 def test_upload_new(self):
     eq_(Extension.objects.count(), 0)
     upload = self.upload('extension')
     extension = Extension.from_upload(upload)
     eq_(extension.version, '0.1')
     eq_(extension.name, u'My Lîttle Extension')
     eq_(extension.default_language, 'en-GB')
     eq_(extension.slug, u'my-lîttle-extension')
     eq_(extension.filename, 'extension-%s.zip' % extension.version)
     ok_(extension.filename in extension.file_path)
     ok_(extension.file_path.startswith(extension.path_prefix))
     ok_(private_storage.exists(extension.file_path))
     eq_(extension.manifest, self.expected_manifest)
     eq_(Extension.objects.count(), 1)
开发者ID:ayushagrawal288,项目名称:zamboni,代码行数:14,代码来源:test_models.py

示例13: test_mini_manifest

    def test_mini_manifest(self):
        manifest = {
            'author': 'Me',
            'description': 'Blah',
            'manifest_version': 2,
            'name': u'Ëxtension',
            'version': '0.44',
        }
        extension = Extension(pk=44, version='0.44.0', manifest=manifest,
                              uuid='abcdefabcdefabcdefabcdefabcdef12')
        expected_manifest = {
            'description': 'Blah',
            'developer': {
                'name': 'Me'
            },
            'name': u'Ëxtension',
            'package_path': extension.download_url,
            'version': '0.44',
        }
        eq_(extension.mini_manifest, expected_manifest)

        # Make sure that mini_manifest is a deepcopy.
        extension.mini_manifest['name'] = u'Faîl'
        eq_(extension.manifest['name'], u'Ëxtension')
开发者ID:shahbaz17,项目名称:zamboni,代码行数:24,代码来源:test_models.py

示例14: create

    def create(self, request, *args, **kwargs):
        upload_pk = request.DATA.get('upload', '')
        if not upload_pk:
            raise exceptions.ParseError(_('No upload identifier specified.'))

        if not request.user.is_authenticated():
            raise exceptions.PermissionDenied(
                _('You need to be authenticated to perform this action.'))

        try:
            upload = FileUpload.objects.get(pk=upload_pk, user=request.user)
        except FileUpload.DoesNotExist:
            raise Http404(_('No such upload.'))
        if not upload.valid:
            raise exceptions.ParseError(
                _('The specified upload has not passed validation.'))

        try:
            obj = Extension.from_upload(upload, user=request.user)
        except ValidationError as e:
            raise exceptions.ParseError(unicode(e))
        log.info('Extension created: %s' % obj.pk)
        serializer = self.get_serializer(obj)
        return Response(serializer.data, status=status.HTTP_201_CREATED)
开发者ID:shahbaz17,项目名称:zamboni,代码行数:24,代码来源:views.py

示例15: test_upload_new

    def test_upload_new(self):
        eq_(Extension.objects.count(), 0)
        upload = self.upload('extension')
        extension = Extension.from_upload(upload, user=self.user)
        ok_(extension.pk)
        eq_(extension.latest_version, ExtensionVersion.objects.latest('pk'))
        eq_(Extension.objects.count(), 1)
        eq_(ExtensionVersion.objects.count(), 1)

        eq_(list(extension.authors.all()), [self.user])
        eq_(extension.name, u'My Lîttle Extension')
        eq_(extension.default_language, 'en-GB')
        eq_(extension.description, u'A Dummÿ Extension')
        eq_(extension.slug, u'my-lîttle-extension')
        eq_(extension.status, STATUS_PENDING)
        ok_(extension.uuid)

        version = extension.latest_version
        eq_(version.version, '0.1')
        eq_(version.default_language, 'en-GB')
        eq_(version.filename, 'extension-%s.zip' % version.version)
        ok_(version.filename in version.file_path)
        ok_(private_storage.exists(version.file_path))
        eq_(version.manifest, self.expected_manifest)
开发者ID:demagu-sr,项目名称:zamboni,代码行数:24,代码来源:test_models.py


注:本文中的mkt.extensions.models.Extension类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。