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


Python StudyPerson.from_name_and_affiliation方法代码示例

本文整理汇总了Python中qiita_db.study.StudyPerson.from_name_and_affiliation方法的典型用法代码示例。如果您正苦于以下问题:Python StudyPerson.from_name_and_affiliation方法的具体用法?Python StudyPerson.from_name_and_affiliation怎么用?Python StudyPerson.from_name_and_affiliation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在qiita_db.study.StudyPerson的用法示例。


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

示例1: test_post_new_person

# 需要导入模块: from qiita_db.study import StudyPerson [as 别名]
# 或者: from qiita_db.study.StudyPerson import from_name_and_affiliation [as 别名]
    def test_post_new_person(self):
        body = {'name': 'Boaty McBoatFace', 'affiliation': 'UCSD',
                'email': '[email protected]', 'phone': '720-876-5309'}

        response = self.post('/api/v1/person', data=body, headers=self.headers)
        self.assertEqual(response.code, 201)
        obs = json_decode(response.body)
        exp = StudyPerson.from_name_and_affiliation(body['name'],
                                                    body['affiliation']).id
        self.assertEqual(exp, obs['id'])
开发者ID:antgonza,项目名称:qiita,代码行数:12,代码来源:test_study_person.py

示例2: get

# 需要导入模块: from qiita_db.study import StudyPerson [as 别名]
# 或者: from qiita_db.study.StudyPerson import from_name_and_affiliation [as 别名]
    def get(self, *args, **kwargs):
        name = self.get_argument('name', None)
        affiliation = self.get_argument('affiliation', None)

        if name is None and affiliation is None:
            # Retrieve the list of all the StudyPerson
            sp = [{'name': p.name, 'affiliation': p.affiliation}
                  for p in StudyPerson.iter()]
            self.write(json_encode(sp))
            self.finish()
        elif name is not None and affiliation is not None:
            try:
                p = StudyPerson.from_name_and_affiliation(name, affiliation)
            except QiitaDBLookupError:
                self.fail('Person not found', 404)
                return
            self.write({'address': p.address, 'phone': p.phone,
                        'email': p.email, 'id': p.id})
            self.finish()
        else:
            arg_name = 'name' if name is None else 'affiliation'
            raise MissingArgumentError(arg_name)
开发者ID:ElDeveloper,项目名称:qiita,代码行数:24,代码来源:study_person.py


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