コード例 #1
0
    def test_deserialize_multi(self):
        apps = [amo.tests.app_factory(), amo.tests.app_factory()]
        app_map = dict((app.id, app.get_indexer().extract_document(app.id)) for app in apps)
        field = AppESField(many=True)
        field.context = {"app_map": app_map, "request": amo.tests.req_factory_factory("")}
        data = field.to_native([app.id for app in apps])

        eq_(len(data), 2)
        eq_(data[0]["id"], apps[0].id)
        eq_(data[1]["id"], apps[1].id)
コード例 #2
0
    def test_deserialize_single(self):
        app = amo.tests.app_factory(description={"en-US": "lol"})
        app_map = {app.id: app.get_indexer().extract_document(app.id)}
        field = AppESField(source="app")
        field.context = {"app_map": app_map, "request": amo.tests.req_factory_factory("")}
        data = field.to_native(app.id)

        eq_(data["id"], app.id)
        eq_(data["slug"], app.app_slug)
        eq_(data["description"], {"en-US": "lol"})
コード例 #3
0
ファイル: test_fields.py プロジェクト: ujdhesa/zamboni
    def test_no_exist(self):
        """
        Handle when the app is not in the app map (as result of filtering).
        """
        app = mkt.site.tests.app_factory()

        field = AppESField()
        field.context = {'app_map': {},
                         'request': mkt.site.tests.req_factory_factory('')}
        data = field.to_native(app.id)
        ok_(not data)
コード例 #4
0
ファイル: test_fields.py プロジェクト: ujdhesa/zamboni
    def test_deserialize_single(self):
        app = mkt.site.tests.app_factory(description={'en-US': 'lol'})
        app_map = {app.id: app.get_indexer().extract_document(app.id)}
        field = AppESField(source='app')
        field.context = {'app_map': app_map,
                         'request': mkt.site.tests.req_factory_factory('')}
        data = field.to_native(app.id)

        eq_(data['id'], app.id)
        eq_(data['slug'], app.app_slug)
        eq_(data['description'], {'en-US': 'lol'})
コード例 #5
0
ファイル: test_fields.py プロジェクト: waseem18/zamboni
    def test_no_exist(self):
        """
        Handle when the app is not in the app map (as result of filtering).
        """
        app = mkt.site.tests.app_factory()

        field = AppESField()
        field.context = {'app_map': {},
                         'request': mkt.site.tests.req_factory_factory('')}
        data = field.to_representation(app.id)
        ok_(not data)
コード例 #6
0
ファイル: test_fields.py プロジェクト: waseem18/zamboni
    def test_deserialize_single(self):
        app = mkt.site.tests.app_factory(description={'en-US': 'lol'})
        app_map = {app.id: app.get_indexer().extract_document(app.id)}
        field = AppESField(source='app')
        field.context = {'app_map': app_map,
                         'request': mkt.site.tests.req_factory_factory('')}
        data = field.to_representation(app.id)

        eq_(data['id'], app.id)
        eq_(data['slug'], app.app_slug)
        eq_(data['description'], {'en-US': 'lol'})
コード例 #7
0
ファイル: test_fields.py プロジェクト: ujdhesa/zamboni
    def test_deserialize_multi(self):
        apps = [mkt.site.tests.app_factory(), mkt.site.tests.app_factory()]
        app_map = dict((app.id, app.get_indexer().extract_document(app.id))
                       for app in apps)
        field = AppESField(many=True)
        field.context = {'app_map': app_map,
                         'request': mkt.site.tests.req_factory_factory('')}
        data = field.to_native([app.id for app in apps])

        eq_(len(data), 2)
        eq_(data[0]['id'], apps[0].id)
        eq_(data[1]['id'], apps[1].id)
コード例 #8
0
ファイル: test_fields.py プロジェクト: waseem18/zamboni
    def test_deserialize_multi(self):
        apps = [mkt.site.tests.app_factory(), mkt.site.tests.app_factory()]
        app_map = dict((app.id, app.get_indexer().extract_document(app.id))
                       for app in apps)
        field = AppESField(many=True)
        field.context = {'app_map': app_map,
                         'request': mkt.site.tests.req_factory_factory('')}
        data = field.to_representation([app.id for app in apps])

        eq_(len(data), 2)
        eq_(data[0]['id'], apps[0].id)
        eq_(data[1]['id'], apps[1].id)
コード例 #9
0
    def test_deserialize_limit(self):
        apps = [amo.tests.app_factory(), amo.tests.app_factory()]
        app_map = dict((app.id, app.get_indexer().extract_document(app.id))
                       for app in apps)
        field = AppESField(many=True, limit=1)
        field.context = {'app_map': app_map,
                         'request': amo.tests.req_factory_factory('')}
        data = field.to_native([app.id for app in apps])

        eq_(len(data), 1)
        eq_(data[0]['id'], apps[0].id)

        field.limit = 0
        data = field.to_native([app.id for app in apps])
        eq_(len(data), 0)
コード例 #10
0
ファイル: test_fields.py プロジェクト: ujdhesa/zamboni
    def test_multi_no_exist(self):
        """
        Handle when the app is not in the app map (as result of filtering).
        """
        apps = [mkt.site.tests.app_factory(), mkt.site.tests.app_factory()]
        app_map = {
            apps[0].id: apps[0].get_indexer().extract_document(apps[0].id)
        }

        field = AppESField(many=True)
        field.context = {'app_map': app_map,
                         'request': mkt.site.tests.req_factory_factory('')}
        data = field.to_native([app.id for app in apps])

        eq_(len(data), 1)
        eq_(data[0]['id'], apps[0].id)
コード例 #11
0
ファイル: test_fields.py プロジェクト: waseem18/zamboni
    def test_multi_no_exist(self):
        """
        Handle when the app is not in the app map (as result of filtering).
        """
        apps = [mkt.site.tests.app_factory(), mkt.site.tests.app_factory()]
        app_map = {
            apps[0].id: apps[0].get_indexer().extract_document(apps[0].id)
        }

        field = AppESField(many=True)
        field.context = {'app_map': app_map,
                         'request': mkt.site.tests.req_factory_factory('')}
        data = field.to_representation([app.id for app in apps])

        eq_(len(data), 1)
        eq_(data[0]['id'], apps[0].id)
コード例 #12
0
    def test_deserialize_limit(self):
        apps = [mkt.site.tests.app_factory(), mkt.site.tests.app_factory()]
        app_map = dict((app.id, app.get_indexer().extract_document(app.id))
                       for app in apps)
        field = AppESField(many=True, limit=1)
        field.context = {'app_map': app_map,
                         'request': mkt.site.tests.req_factory_factory('')}
        data = field.to_native([app.id for app in apps])

        eq_(len(data), 1)
        eq_(data[0]['id'], apps[0].id)

        field.limit = 0
        data = field.to_native([app.id for app in apps])
        eq_(len(data), 0)