コード例 #1
0
ファイル: test_models.py プロジェクト: jasonmyers/gamelocal
    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')
コード例 #2
0
ファイル: test_models.py プロジェクト: jasonmyers/gamelocal
    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')
コード例 #3
0
ファイル: test_models.py プロジェクト: jasonmyers/gamelocal
    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',
        )
コード例 #4
0
ファイル: test_models.py プロジェクト: jasonmyers/gamelocal
    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
コード例 #5
0
ファイル: test_models.py プロジェクト: jasonmyers/gamelocal
    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
コード例 #6
0
ファイル: test_models.py プロジェクト: jasonmyers/gamelocal
    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',
        )