Ejemplo n.º 1
0
    def test_0030_model_pagination_serialization(self):
        """
        Test serialization of pagination for models
        """
        self.setup_defaults()

        # Create a 100 nereid users
        for id in xrange(0, 100):
            self.nereid_user_obj.create([{
                'party': self.guest_party,
                'display_name': 'User %s' % id,
                'email': '*****@*****.**' % id,
                'password': '******',
                'company': self.company.id,
            }])

        pagination = Pagination(self.nereid_user_obj, [], 1, 10)
        serialized = pagination.serialize()

        self.assertEqual(serialized['count'], 100)
        self.assertEqual(serialized['pages'], 10)
        self.assertEqual(serialized['page'], 1)
        self.assertEqual(len(serialized['items']), 10)

        self.assert_('display_name' in serialized['items'][0])
Ejemplo n.º 2
0
    def test_0030_model_pagination_serialization(self):
        """
        Test serialization of pagination for models
        """
        with Transaction().start(DB_NAME, USER, CONTEXT):
            self.setup_defaults()

            # Create a 100 nereid users
            for id in xrange(0, 100):
                self.nereid_user_obj.create([{
                    'party': self.guest_party,
                    'display_name': 'User %s' % id,
                    'email': '*****@*****.**' % id,
                    'password': '******',
                    'company': self.company.id,
                }])

            pagination = Pagination(self.nereid_user_obj, [], 1, 10)
            serialized = pagination.serialize()

            self.assertEqual(serialized['count'], 100)
            self.assertEqual(serialized['pages'], 10)
            self.assertEqual(serialized['page'], 1)
            self.assertEqual(len(serialized['items']), 10)

            self.assert_('display_name' in serialized['items'][0])
Ejemplo n.º 3
0
    def test_0040_model_pagination_serialization(self):
        """
        Test serialization of pagination for model which does not have
        serialize method
        """
        self.setup_defaults()

        # Create a 100 addresses
        for id in xrange(0, 100):
            self.address_obj.create([{
                'party': self.guest_party,
                'name': 'User %s' % id,
            }])

        pagination = Pagination(self.address_obj, [], 1, 10)
        serialized = pagination.serialize()

        self.assert_('id' in serialized['items'][0])
        self.assert_('rec_name' in serialized['items'][0])
Ejemplo n.º 4
0
    def test_0040_model_pagination_serialization(self):
        """
        Test serialization of pagination for model which does not have
        serialize method
        """
        self.setup_defaults()

        # Create a 100 addresses
        for id in xrange(0, 100):
            self.address_obj.create([{
                'party': self.guest_party,
                'name': 'User %s' % id,
            }])

        pagination = Pagination(self.address_obj, [], 1, 10)
        serialized = pagination.serialize()

        self.assert_('id' in serialized['items'][0])
        self.assert_('rec_name' in serialized['items'][0])