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


Python Paper.get_or_create方法代码示例

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


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

示例1: test_multiple_get_or_create

# 需要导入模块: from papers.models import Paper [as 别名]
# 或者: from papers.models.Paper import get_or_create [as 别名]
    def test_multiple_get_or_create(self):
        date = datetime.date(year=2003, month=4, day=9)
        paper = Paper.get_or_create('Beta-rays in black pudding',
                                    list(map(Name.lookup_name, [
                                        ('F.', 'Rodrigo'), ('A.', 'Johnson'), ('Pete', 'Blunsom')])),
                                    date)

        paper2 = Paper.get_or_create('Beta-rays in black pudding',
                                     list(map(Name.lookup_name, [
                                         ('Frank', 'Rodrigo'), ('A. L.', 'Johnson'), ('P.', 'Blunsom')])),
                                     date)

        self.assertEqual(paper.pk, paper2.pk)
        self.assertEqual(Paper.objects.get(pk=paper.pk).bare_author_names(),
                         [('Frank', 'Rodrigo'), ('A. L.', 'Johnson'), ('Pete', 'Blunsom')])
开发者ID:Phyks,项目名称:dissemin,代码行数:17,代码来源:test_generic.py

示例2: setUpClass

# 需要导入模块: from papers.models import Paper [as 别名]
# 或者: from papers.models.Paper import get_or_create [as 别名]
 def setUpClass(self):
     super(ProtocolTest, self).setUpClass()
     if self is ProtocolTest:
          raise unittest.SkipTest("Base test")
     if 'TRAVIS' in os.environ:
         raise unittest.SkipTest("Skipping deposit test on Travis to avoid mass submissions to sandboxes")
     self.p1 = Paper.get_or_create(
             "This is a test paper",
             [self.r1.name, self.r2.name, self.r4.name],
             date(year=2014,month=02,day=15))
开发者ID:Lysxia,项目名称:dissemin,代码行数:12,代码来源:tests.py

示例3: test_paper_with_empty_slug

# 需要导入模块: from papers.models import Paper [as 别名]
# 或者: from papers.models.Paper import get_or_create [as 别名]
 def test_paper_with_empty_slug(self):
     """
     Papers may have titles with characters that
     are all ignored by slugify.
     """
     p = Paper.get_or_create(
         '[email protected]#$%^*()',
         [BareName.create('Jean', 'Saisrien')],
         datetime.date(2016, 7, 2))
     p.visible = True # Force paper to be visible even if it an orphan
     p.save()
     self.assertEqual(p.slug, '')
     self.checkPage('paper', args=[p.pk, p.slug])
开发者ID:dissemin,项目名称:dissemin,代码行数:15,代码来源:test_pages.py

示例4: setUp

# 需要导入模块: from papers.models import Paper [as 别名]
# 或者: from papers.models.Paper import get_or_create [as 别名]
    def setUp(self):
        if type(self) is ProtocolTest:
            raise unittest.SkipTest("Base test")
        self.p1 = Paper.get_or_create(
                "This is a test paper",
                [self.r1.name, self.r2.name, self.r4.name],
                date(year=2014, month=2, day=15))

        self.username = 'mydepositinguser'
        self.password = 'supersecret'
        self.user = User.objects.create_user(username=self.username, email="[email protected]", password=self.password)
        self.testdir = os.path.dirname(os.path.abspath(__file__))
        self.pdfpath = os.path.join(self.testdir, 'data/blank.pdf')
开发者ID:Phyks,项目名称:dissemin,代码行数:15,代码来源:test_protocol.py

示例5: test_update_authors

# 需要导入模块: from papers.models import Paper [as 别名]
# 或者: from papers.models.Paper import get_or_create [as 别名]
 def test_update_authors(self):
     for old_author_names, new_author_names, final in [
             ([('G.', 'Bodenhausen')],
              [('Geoffrey', 'Bodenhausen')],
              [('Geoffrey', 'Bodenhausen')]),
             ([('L. F.', 'Jullien'), ('A.', 'Amarilli')],
              [('Ludovic', 'Jullien'), ('R.', 'Pérand'), ('Antoine', 'Amarilli')],
              [('Ludovic F.', 'Jullien'), ('R.', 'Pérand'), ('Antoine', 'Amarilli')]),
             ]:
         paper = Paper.get_or_create('This is a test paper',
                                     [BareName.create_bare(f, l) for (
                                         f, l) in old_author_names],
                                     datetime.date(year=2015, month=0o4, day=0o5))
         new_authors = [BareAuthor(name=BareName.create_bare(f, l))
                        for (f, l) in new_author_names]
         paper.update_authors(new_authors)
         self.assertEqual(paper.bare_author_names(), final)
开发者ID:Phyks,项目名称:dissemin,代码行数:19,代码来源:test_generic.py


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