本文整理汇总了Python中tests.create_elections函数的典型用法代码示例。如果您正苦于以下问题:Python create_elections函数的具体用法?Python create_elections怎么用?Python create_elections使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_elections函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: test_generate_cache_no_picture_folder
def test_generate_cache_no_picture_folder(self):
""" Test the generate_cache function. """
create_elections(self.session)
election = nuancierlib.get_election(self.session, 2)
self.assertRaises(
nuancierlib.NuancierException,
nuancierlib.generate_cache,
session=self.session,
election=election,
picture_folder='none',
cache_folder=CACHE_FOLDER,
size=(128, 128)
)
开发者ID:vivekanand1101,项目名称:nuancier,代码行数:15,代码来源:test_nuancierlib.py
示例17: 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),
{
'author': u'pingou',
'license': u'CC-BY-SA',
'name': u'Image ok',
'original_url': None,
'submitter': u'pingou',
}
)
开发者ID:ryanlerch,项目名称:nuancier,代码行数:16,代码来源:test_model.py
示例18: test_toggle_public
def test_toggle_public(self):
""" Test the toggle_public function. """
create_elections(self.session)
election = nuancierlib.get_election(self.session, 1)
self.assertEqual(True, election.election_public)
nuancierlib.toggle_public(self.session, 1)
election = nuancierlib.get_election(self.session, 1)
self.assertEqual(False, election.election_public)
nuancierlib.toggle_public(self.session, 1)
election = nuancierlib.get_election(self.session, 1)
self.assertEqual(True, election.election_public)
开发者ID:anshprat,项目名称:nuancier-lite,代码行数:16,代码来源:test_nuancierlib.py
示例19: test_add_vote
def test_add_vote(self):
""" Test the add_vote function. """
create_elections(self.session)
create_candidates(self.session)
nuancierlib.add_vote(
session=self.session,
candidate_id=2,
username='pingou'
)
self.session.commit()
votes = nuancierlib.get_votes_user(self.session, 1, 'pingou')
self.assertEqual(1, len(votes))
self.assertEqual(2, votes[0].candidate_id)
开发者ID:vivekanand1101,项目名称:nuancier,代码行数:16,代码来源:test_nuancierlib.py
示例20: 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),
{
'date_end': TODAY - timedelta(days=8),
'date_start': TODAY - timedelta(days=10),
'id': 1,
'name': u'Wallpaper F19',
'submission_date_start': TODAY - timedelta(days=15),
'year': 2013
}
)
开发者ID:ryanlerch,项目名称:nuancier,代码行数:17,代码来源:test_model.py
注:本文中的tests.create_elections函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论