def test_unicode_choices_for(self): from tests.clubs.factories import GoClubFactory from app.clubs.models import CLUB_GAME_CHOICES club = GoClubFactory() self.assertEqual(club.choices_for('game'), dict(CLUB_GAME_CHOICES)) self.assertRaises(AttributeError, club.choices_for, 'name')
def test_unicode_choices_for(self): from tests.clubs.factories import GoClubFactory from app.clubs.models import CLUB_GAME_CHOICES club = GoClubFactory() self.assertEqual( club.choices_for('game'), dict(CLUB_GAME_CHOICES) ) self.assertRaises(AttributeError, club.choices_for, 'name')
def test_unicode_label_for_choice(self): from tests.clubs.factories import GoClubFactory from app.clubs.models import CLUB_GAME_CHOICES club = GoClubFactory() self.assertEqual(club.label_for_choice('game', 'go'), dict(CLUB_GAME_CHOICES)['go']) self.assertRaises(KeyError, club.label_for_choice, 'game', 'parcheesi') self.assertRaises( AttributeError, club.label_for_choice, 'name', 'go', )
def test_unicode_choices_model_commit(self): from tests.clubs.factories import GoClubFactory from app.clubs.models import Club club = GoClubFactory() club.country_code = '!!' self.assertLength(Club.query.all(), 0) db.session.add(club) try: db.session.commit() except StatementError as e: self.assertIn('Invalid choice', e.message) db.session.rollback() self.assertLength(Club.query.all(), 0) else: raise self.failureException
def test_unicode_label_for_choice(self): from tests.clubs.factories import GoClubFactory from app.clubs.models import CLUB_GAME_CHOICES club = GoClubFactory() self.assertEqual( club.label_for_choice('game', 'go'), dict(CLUB_GAME_CHOICES)['go'] ) self.assertRaises( KeyError, club.label_for_choice, 'game', 'parcheesi' ) self.assertRaises( AttributeError, club.label_for_choice, 'name', 'go', )