• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python mock.PersonModel类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_filter_datetime_field

    def test_filter_datetime_field(self):
        """Test filtering by a datetime field."""
        PersonModel.mock()

        parameters = {'filter[created_at]': date.today().strftime('%Y-%m-%d')}
        query = Resource(self.model, parameters).filter_query(self.query)

        result = query.all()
        self.assertEqual(len(result), 1)
开发者ID:caxiam,项目名称:sqlalchemy-jsonapi-collections,代码行数:9,代码来源:filter_tests.py


示例2: test_filter_computed_field

    def test_filter_computed_field(self):
        """Test filtering by a computed field."""
        PersonModel.mock(is_employed=True)

        parameters = {'filter[employed_integer]': '1'}
        query = Resource(self.model, parameters).filter_query(self.query)

        result = query.all()
        self.assertEqual(len(result), 1)
开发者ID:caxiam,项目名称:sqlalchemy-jsonapi-collections,代码行数:9,代码来源:filter_tests.py


示例3: test_filter_decimal_field

    def test_filter_decimal_field(self):
        """Test filtering by a decimal field."""
        PersonModel.mock(rate='12.51')

        parameters = {'filter[rate]': '12.51'}
        query = Resource(self.model, parameters).filter_query(self.query)

        result = query.all()
        self.assertEqual(len(result), 1)
开发者ID:caxiam,项目名称:sqlalchemy-jsonapi-collections,代码行数:9,代码来源:filter_tests.py


示例4: test_filter_multiple_string_field

    def test_filter_multiple_string_field(self):
        """Test filtering by multiple string fields."""
        PersonModel.mock(name='A PRODUCT Wildcard')

        parameters = {'filter[name]': 'prod,test,card'}
        query = Resource(self.model, parameters).filter_query(self.query)

        result = query.all()
        self.assertEqual(len(result), 1)
开发者ID:caxiam,项目名称:sqlalchemy-jsonapi-collections,代码行数:9,代码来源:filter_tests.py


示例5: test_filter_enum_field

    def test_filter_enum_field(self):
        """Test filtering by an enum field."""
        PersonModel.mock(gender='male')

        parameters = {'filter[gender]': 'male'}
        query = Resource(self.model, parameters).filter_query(self.query)

        result = query.all()
        self.assertEqual(len(result), 1)
开发者ID:caxiam,项目名称:sqlalchemy-jsonapi-collections,代码行数:9,代码来源:filter_tests.py


示例6: test_filter_boolean_field

    def test_filter_boolean_field(self):
        """Test filtering by a boolean field."""
        PersonModel.mock(is_employed=True)

        parameters = {'filter[is_employed]': '1'}
        query = Resource(self.model, parameters).filter_query(self.query)

        result = query.all()
        self.assertEqual(len(result), 1)
开发者ID:caxiam,项目名称:sqlalchemy-jsonapi-collections,代码行数:9,代码来源:filter_tests.py


示例7: test_filter_integer_field

    def test_filter_integer_field(self):
        """Test filtering by an integer field."""
        PersonModel.mock(age=80)

        parameters = {'filter[age]': '80'}
        query = Resource(self.model, parameters).filter_query(self.query)

        result = query.all()
        self.assertEqual(len(result), 1)
开发者ID:caxiam,项目名称:sqlalchemy-jsonapi-collections,代码行数:9,代码来源:filter_tests.py


示例8: test_filter_many_to_many_relationship

    def test_filter_many_to_many_relationship(self):
        """Test filtering by a many-to-many relationship field."""
        company = CompanyModel.mock(name="company")
        PersonModel.mock(companies=[company])

        parameters = {'filter[companies.name]': 'COMPANY'}
        query = Resource(self.model, parameters).filter_query(self.query)

        result = query.all()
        self.assertEqual(len(result), 1)
开发者ID:caxiam,项目名称:sqlalchemy-jsonapi-collections,代码行数:10,代码来源:filter_tests.py


示例9: test_sort_field_descending

    def test_sort_field_descending(self):
        """Test sorting a field in descending order."""
        PersonModel.mock(name="A")
        PersonModel.mock(name="B")

        parameters = {'sort': '-name'}
        query = Resource(self.model, parameters).sort_query(self.query)

        result = query.all()
        self.assertEqual(result[0].name, 'B')
开发者ID:caxiam,项目名称:sqlalchemy-jsonapi-collections,代码行数:10,代码来源:sort_tests.py


示例10: test_filter_string_field

    def test_filter_string_field(self):
        """Test filtering by a string field."""
        PersonModel.mock(name='A PRODUCT Wildcard')

        parameters = {'filter[name]': 'prod'}
        query = Resource(
            self.model, parameters, MarshmallowDriver, PersonSchema).\
            filter_query(self.query)

        result = query.all()
        self.assertEqual(len(result), 1)
开发者ID:caxiam,项目名称:sqlalchemy-jsonapi-collections,代码行数:11,代码来源:filter_tests.py


示例11: test_offset

    def test_offset(self):
        """Test offsetting a page by the offset parameter."""
        PersonModel.mock(name='First')
        PersonModel.mock(name='Second')

        parameters = {'offset': '1'}
        query = Resource(self.model, parameters).paginate_query(self.query)

        result = query.all()
        self.assertEqual(len(result), 1)
        self.assertTrue(result[0].name == 'Second')
开发者ID:caxiam,项目名称:sqlalchemy-jsonapi-collections,代码行数:11,代码来源:page_tests.py


示例12: test_page_size

    def test_page_size(self):
        """Test limiting a page by the page[size] parameter."""
        PersonModel.mock(name='First')
        PersonModel.mock(name='Second')

        parameters = {'page[size]': '1'}
        query = Resource(self.model, parameters).paginate_query(self.query)

        result = query.all()
        self.assertEqual(len(result), 1)
        self.assertTrue(result[0].name == 'First')
开发者ID:caxiam,项目名称:sqlalchemy-jsonapi-collections,代码行数:11,代码来源:page_tests.py


示例13: test_include_foreign_key

    def test_include_foreign_key(self):
        """Test including a foreign key relationship field."""
        PersonModel.mock()
        model = EmployeeModel.mock(person_id=1)

        include = ['person']
        iv_objects, errors = IncludeValue.generate(EmployeeSchema, include)
        data = IncludeValue.include(iv_objects, model)

        self.assertTrue(errors == [])
        self.assertTrue(len(data) == 1)
开发者ID:Raistlfiren,项目名称:sqlalchemy-jsonapi-collections,代码行数:11,代码来源:include_tests.py


示例14: test_sort_field_ascending

    def test_sort_field_ascending(self):
        """Test sorting a field in ascending order."""
        PersonModel.mock(name="A")
        PersonModel.mock(name="B")

        parameters = {'sort': 'name'}
        query = Resource(
            self.model, parameters, marshmallow.MarshmallowDriver, self.view).\
            sort_query(self.query)

        result = query.all()
        self.assertEqual(result[0].name, 'A')
开发者ID:caxiam,项目名称:sqlalchemy-jsonapi-collections,代码行数:12,代码来源:sort_tests.py


示例15: test_filter_decimal_field_invalid_value

    def test_filter_decimal_field_invalid_value(self):
        """Test filtering by an invalid decimal value."""
        PersonModel.mock(rate='12.51')

        try:
            parameters = {'filter[rate]': 'a'}
            Resource(self.model, parameters).filter_query(self.query)
        except JSONAPIError as exc:
            message = exc.message
            self.assertIn('detail', message['errors'][0])
            self.assertTrue(
                message['errors'][0]['source']['parameter'] == 'filter[rate]')
开发者ID:caxiam,项目名称:sqlalchemy-jsonapi-collections,代码行数:12,代码来源:filter_tests.py


示例16: test_sort_invalid_relationship

    def test_sort_invalid_relationship(self):
        """Test sorting against non-existant relationship attribute."""
        PersonModel.mock()

        try:
            parameters = {'sort': 'companies.x'}
            Resource(self.model, parameters).sort_query(self.query)
        except JSONAPIError as exc:
            message = exc.message
            self.assertTrue(
                message['errors'][0]['source']['parameter'] == 'sort')
            self.assertIn('detail', message['errors'][0])
开发者ID:caxiam,项目名称:sqlalchemy-jsonapi-collections,代码行数:12,代码来源:sort_tests.py


示例17: test_sort_relationship_descending

    def test_sort_relationship_descending(self):
        """Test sorting a relationhip's field in descending order."""
        a = CompanyModel.mock(name="Last")
        b = CompanyModel.mock(name="First")
        PersonModel.mock(name="A", companies=[a])
        PersonModel.mock(name="B", companies=[b])

        parameters = {'sort': '-companies.name'}
        query = Resource(self.model, parameters).sort_query(self.query)

        result = query.all()
        self.assertEqual(result[0].companies[0].name, 'Last')
开发者ID:caxiam,项目名称:sqlalchemy-jsonapi-collections,代码行数:12,代码来源:sort_tests.py


示例18: test_limit

    def test_limit(self):
        """Test limiting a page by the limit parameter."""
        PersonModel.mock(name='First')
        PersonModel.mock(name='Second')

        parameters = {'limit': '1'}
        query = Resource(
            self.model, parameters, MarshmallowDriver, PersonSchema).\
            paginate_query(self.query)

        result = query.all()
        self.assertEqual(len(result), 1)
        self.assertTrue(result[0].name == 'First')
开发者ID:caxiam,项目名称:sqlalchemy-jsonapi-collections,代码行数:13,代码来源:page_tests.py


示例19: test_page_number

    def test_page_number(self):
        """Test offsetting a page by the page[number] parameter."""
        PersonModel.mock(name='First')
        PersonModel.mock(name='Second')

        parameters = {'page[number]': '1', 'page[size]': '1'}
        query = Resource(
            self.model, parameters, MarshmallowDriver, PersonSchema).\
            paginate_query(self.query)

        result = query.all()
        self.assertEqual(len(result), 1)
        self.assertTrue(result[0].name == 'Second')
开发者ID:caxiam,项目名称:sqlalchemy-jsonapi-collections,代码行数:13,代码来源:page_tests.py


示例20: test_filter_enum_field_invalid_value

    def test_filter_enum_field_invalid_value(self):
        """Test filtering by an invalid enum value."""
        PersonModel.mock(gender='male')

        try:
            parameters = {'filter[gender]': 'mal'}
            Resource(self.model, parameters).filter_query(self.query)
        except JSONAPIError as exc:
            message = exc.message
            self.assertIn('detail', message['errors'][0])
            self.assertTrue(
                message['errors'][0]['source']['parameter'] ==
                'filter[gender]')
开发者ID:caxiam,项目名称:sqlalchemy-jsonapi-collections,代码行数:13,代码来源:filter_tests.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python zwave.value_changed函数代码示例发布时间:2022-05-27
下一篇:
Python mock.patch函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap