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


Python tests.create_elections函数代码示例

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


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

示例1: test_get_elections_open

    def test_get_elections_open(self):
        """ Test the get_elections_open function. """
        create_elections(self.session)

        elections = nuancierlib.get_elections_open(self.session)
        self.assertEqual(1, len(elections))
        self.assertEqual('Wallpaper F20', elections[0].election_name)
开发者ID:vivekanand1101,项目名称:nuancier,代码行数:7,代码来源:test_nuancierlib.py

示例2: test_edit_election

    def test_edit_election(self):
        """ Test the edit_election function. """
        create_elections(self.session)
        election = nuancierlib.get_election(self.session, 2)

        new_election = nuancierlib.edit_election(
            self.session,
            election=election,
            election_name='elec name',
            election_folder='Test',
            election_year=2048,
            election_date_start=TODAY,
            election_date_end=TODAY + timedelta(days=2),
            submission_date_start=TODAY - timedelta(days=2),
            election_n_choice=42,
            election_badge_link='http://badges.fp.o/1234',
            user='pingou',
        )

        self.assertEqual(new_election.election_name, 'elec name')
        self.assertEqual(new_election.election_folder, 'Test')
        self.assertEqual(new_election.election_year, 2048)
        self.assertEqual(new_election.election_date_start, TODAY)
        self.assertEqual(
            new_election.election_date_end, TODAY + timedelta(days=2))
        self.assertEqual(
            new_election.submission_date_start, TODAY - timedelta(days=2))
        self.assertEqual(new_election.election_n_choice, 42)
        self.assertEqual(
            new_election.election_badge_link, 'http://badges.fp.o/1234')
开发者ID:grdryn,项目名称:nuancier,代码行数:30,代码来源:test_nuancierlib.py

示例3: test_get_candidate

    def test_get_candidate(self):
        """ Test the get_candidate function. """
        create_elections(self.session)
        create_candidates(self.session)

        candidate = nuancierlib.get_candidate(self.session, 1)
        self.assertEqual('DSC_0951', candidate.candidate_name)

        candidate = nuancierlib.get_candidate(self.session, 4)
        self.assertEqual('DSC_0922', candidate.candidate_name)
开发者ID:stickster,项目名称:nuancier-lite,代码行数:10,代码来源:test_nuancierlib.py

示例4: test_get_votes_user

    def test_get_votes_user(self):
        """ Test the get_votes_user function. """
        create_elections(self.session)
        create_candidates(self.session)
        create_votes(self.session)

        votes = nuancierlib.get_votes_user(self.session, 1, 'pingou')
        self.assertEqual(2, len(votes))
        self.assertEqual(1, votes[0].candidate_id)
        self.assertEqual(2, votes[1].candidate_id)
开发者ID:vivekanand1101,项目名称:nuancier,代码行数:10,代码来源:test_nuancierlib.py

示例5: test_get_stats

    def test_get_stats(self):
        """ Test the get_stats function. """
        create_elections(self.session)
        create_candidates(self.session)
        create_votes(self.session)

        stats = nuancierlib.get_stats(self.session, 1)
        self.assertEqual(5, stats['votes'])
        self.assertEqual(3, stats['voters'])
        self.assertEqual([[1, 1], [2, 2]], stats['data'])
开发者ID:vivekanand1101,项目名称:nuancier,代码行数:10,代码来源:test_nuancierlib.py

示例6: test_get_candidate

    def test_get_candidate(self):
        """ Test the get_candidate function. """
        create_elections(self.session)
        create_candidates(self.session)

        candidate = nuancierlib.get_candidate(self.session, 1)
        self.assertEqual('Image ok', candidate.candidate_name)

        candidate = nuancierlib.get_candidate(self.session, 10)
        self.assertEqual(None, candidate)
开发者ID:vivekanand1101,项目名称:nuancier,代码行数:10,代码来源:test_nuancierlib.py

示例7: test_elections_repr

    def test_elections_repr(self):
        """ Test the __repr__ function of Elections. """
        create_elections(self.session)
        create_candidates(self.session)

        election = nuancierlib.get_election(self.session, 1)
        self.assertEqual(
            election.__repr__(),
            "Elections(id:1, name:u'Wallpaper F19', year:2013)"
        )
开发者ID:anshprat,项目名称:nuancier-lite,代码行数:10,代码来源:test_model.py

示例8: test_elections_api_repr

    def test_elections_api_repr(self):
        """ Test the api_repr function of Elections. """
        create_elections(self.session)
        create_candidates(self.session)

        election = nuancierlib.get_election(self.session, 1)
        self.assertEqual(
            election.api_repr(1),
            {'name': 'Wallpaper F19', 'year': 2013}
        )
开发者ID:anshprat,项目名称:nuancier-lite,代码行数:10,代码来源:test_model.py

示例9: test_candidates_api_repr

    def test_candidates_api_repr(self):
        """ Test the api_repr function of Elections. """
        create_elections(self.session)
        create_candidates(self.session)

        candidate = nuancierlib.get_candidate(self.session, 1)
        self.assertEqual(
            candidate.api_repr(1),
            {'election': u'Wallpaper F19', 'name': u'DSC_0951'}
        )
开发者ID:anshprat,项目名称:nuancier-lite,代码行数:10,代码来源:test_model.py

示例10: test_add_candidate

    def test_add_candidate(self):
        """ Test the add_candidate function. """
        create_elections(self.session)

        self.assertRaises(
            nuancierlib.NuancierException,
            nuancierlib.add_candidate,
            session=self.session,
            candidate_file='test.png',
            candidate_name='test image',
            candidate_author='pingou',
            candidate_license='CC-BY-SA',
            candidate_submitter='pingou',
            submitter_email='[email protected]',
            candidate_original_url=None,
            election_id=2,
        )

        nuancierlib.add_candidate(
            session=self.session,
            candidate_file='test.png',
            candidate_name='test image',
            candidate_author='pingou',
            candidate_license='CC-BY-SA',
            candidate_submitter='pingou',
            submitter_email='[email protected]',
            candidate_original_url=None,
            election_id=2,
            user='pingou',
        )
        self.session.commit()

        candidates = nuancierlib.get_candidates(self.session, 2, False)
        self.assertEqual(1, len(candidates))
        self.assertEqual('test image', candidates[0].candidate_name)
        self.assertEqual('test.png', candidates[0].candidate_file)

        candidates = nuancierlib.get_candidates(self.session, 2, True)
        self.assertEqual(0, len(candidates))

        self.assertRaises(
            nuancierlib.NuancierException,
            nuancierlib.add_candidate,
            session=self.session,
            candidate_file='test.png',
            candidate_name='test image',
            candidate_author='pingou',
            candidate_license='CC-BY-SA',
            candidate_submitter='pingou',
            submitter_email='[email protected]',
            candidate_original_url='http://example.org',
            election_id=2,
            user='pingou',
        )
开发者ID:vivekanand1101,项目名称:nuancier,代码行数:54,代码来源:test_nuancierlib.py

示例11: test_election_public

    def test_election_public(self):
        """ Test the election_public property of Elections. """
        create_elections(self.session)

        election = nuancierlib.get_election(self.session, 1)
        self.assertEqual(election.election_public, True)

        election = nuancierlib.get_election(self.session, 2)
        self.assertEqual(election.election_public, False)

        election = nuancierlib.get_election(self.session, 3)
        self.assertEqual(election.election_public, False)
开发者ID:stickster,项目名称:nuancier-lite,代码行数:12,代码来源:test_model.py

示例12: test_get_results

    def test_get_results(self):
        """ Test the get_results function. """
        create_elections(self.session)
        create_candidates(self.session)
        create_votes(self.session)

        results = nuancierlib.get_results(self.session, 1)
        self.assertEqual(2, len(results))
        self.assertEqual('Image ok', results[0][0].candidate_name)  # candidate
        self.assertEqual(3, results[0][1])  # number of votes
        self.assertEqual('Image too narrow', results[1][0].candidate_name)
        self.assertEqual(2, results[1][1])
开发者ID:vivekanand1101,项目名称:nuancier,代码行数:12,代码来源:test_nuancierlib.py

示例13: test_votes_repr

    def test_votes_repr(self):
        """ Test the __repr__ function of Votes. """
        create_elections(self.session)
        create_candidates(self.session)
        create_votes(self.session)

        votes = nuancierlib.get_votes_user(self.session, 1, 'pingou')
        self.assertTrue(
            votes[0].__repr__().startswith(
                "Votes(name:u'pingou', candidate_id:1, created:"
            )
        )
开发者ID:anshprat,项目名称:nuancier-lite,代码行数:12,代码来源:test_model.py

示例14: test_candidates_repr

    def test_candidates_repr(self):
        """ Test the __repr__ function of Candidates. """
        create_elections(self.session)
        create_candidates(self.session)

        candidate = nuancierlib.get_candidate(self.session, 1)
        self.assertTrue(
            candidate.__repr__().startswith(
                "Candidates(file:u'DSC_0951.JPG', "
                       "name:u'DSC_0951', "
                       "election_id:1, "
            )
        )
开发者ID:anshprat,项目名称:nuancier-lite,代码行数:13,代码来源:test_model.py

示例15: test_get_candidates

    def test_get_candidates(self):
        """ Test the get_candidates function. """
        create_elections(self.session)
        create_candidates(self.session)

        candidates = nuancierlib.get_candidates(self.session, 1)
        self.assertEqual(2, len(candidates))
        self.assertEqual('DSC_0930', candidates[0].candidate_name)
        self.assertEqual('DSC_0951', candidates[1].candidate_name)

        candidates = nuancierlib.get_candidates(self.session, 2)
        self.assertEqual(2, len(candidates))
        self.assertEqual('DSC_0922', candidates[0].candidate_name)
        self.assertEqual('DSC_0923', candidates[1].candidate_name)
开发者ID:stickster,项目名称:nuancier-lite,代码行数:14,代码来源:test_nuancierlib.py


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