コード例 #1
0
 def setUp(self):
     self.user = User.objects.first()
     self.event = Event(**EVENT_DATA)
     self.proposal = Proposal(**PROPOSAL_DATA)
     self.vote = Vote(user_id=self.event.author_id,
                      proposal=self.proposal,
                      rate=3)
コード例 #2
0
class ProposalObjectTest(TestCase):
    fixtures = ['user.json']

    def setUp(self):
        self.user = User.objects.first()
        self.event = Event(**EVENT_DATA)
        self.proposal = Proposal(**PROPOSAL_DATA)
        self.vote = Vote(user_id=self.event.author_id,
                         proposal=self.proposal, rate=3)

    def test_assert_proposal_unicode_representation(self):
        self.assertEquals(u'Python For Zombies', unicode(self.proposal))

    def test_assert_proposal_title(self):
        self.assertEquals(u'Python For Zombies', self.proposal.title)

    def test_assert_proposal_description(self):
        self.assertEquals(u'Brain...', self.proposal.description)

    def test_assert_proposal_author(self):
        self.assertEquals(1, self.proposal.author_id)

    def test_assert_proposal_rate(self):
        self.assertEquals(0, self.proposal.rate)

    def test_assert_user_cannot_vote_multiple_times(self):
        self.event.save()
        self.proposal.event = self.event
        self.proposal.author = User.objects.get(id=2)
        self.proposal.save()
        self.vote.proposal = self.proposal
        self.vote.save()

        self.assertTrue(self.proposal.user_already_votted(self.user))
コード例 #3
0
ファイル: test_unit.py プロジェクト: berinhard/speakerfight
 def setUp(self):
     self.user = User.objects.first()
     self.event = Event(**EVENT_DATA)
     self.proposal = Proposal(**PROPOSAL_DATA)
     self.vote = Vote(user_id=self.event.author_id,
                      proposal=self.proposal, rate=3)
コード例 #4
0
ファイル: test_unit.py プロジェクト: berinhard/speakerfight
class ProposalObjectTest(TestCase):
    fixtures = ['user.json']

    def setUp(self):
        self.user = User.objects.first()
        self.event = Event(**EVENT_DATA)
        self.proposal = Proposal(**PROPOSAL_DATA)
        self.vote = Vote(user_id=self.event.author_id,
                         proposal=self.proposal, rate=3)

    @unittest.skipIf(six.PY3, 'not test unicode on python3')
    def test_assert_proposal_unicode_representation(self):
        self.assertEquals(u'Python For Zombies', six.text_type(self.proposal))

    def test_assert_proposal_title(self):
        self.assertEquals(u'Python For Zombies', self.proposal.title)

    def test_assert_proposal_description(self):
        self.assertEquals(u'Brain...', self.proposal.description)

    def test_assert_proposal_author(self):
        self.assertEquals(1, self.proposal.author_id)

    def test_assert_proposal_rate(self):
        self.assertEquals(0, self.proposal.get_rate)

    def test_get_absolute_url(self):
        self.proposal.event = self.event
        self.assertEquals('/events/rupy/#python-for-zombies',
                          self.proposal.get_absolute_url())

    def test_assert_user_cannot_vote_multiple_times(self):
        self.event.save()
        self.proposal.event = self.event
        self.proposal.author = User.objects.get(id=2)
        self.proposal.save()
        self.vote.proposal = self.proposal
        self.vote.save()

        self.assertTrue(self.proposal.user_already_voted(self.user))

    def test_assert_proposal_is_published(self):
        self.assertEquals(True, self.proposal.is_published)

    def test_assert_proposal_approve(self):
        self.event.save()
        self.proposal.event = self.event
        self.proposal.save()

        self.assertEquals(False, self.proposal.is_approved)
        self.proposal.approve()
        self.assertEquals(True, self.proposal.is_approved)

    def test_assert_proposal_disapprove(self):
        self.event.save()
        self.proposal.event = self.event
        self.proposal.is_approved = True
        self.proposal.save()

        self.assertEquals(True, self.proposal.is_approved)
        self.proposal.disapprove()
        self.assertEquals(False, self.proposal.is_approved)
コード例 #5
0
 def setUp(self):
     self.event = Event(**EVENT_DATA)
     self.proposal = Proposal(event=self.event, **PROPOSAL_DATA)
     self.vote = Vote(user_id=self.event.author_id,
                      proposal=self.proposal,
                      rate=3)
コード例 #6
0
class ProposalObjectTest(TestCase):
    fixtures = ['user.json']

    def setUp(self):
        self.user = User.objects.first()
        self.event = Event(**EVENT_DATA)
        self.proposal = Proposal(**PROPOSAL_DATA)
        self.vote = Vote(user_id=self.event.author_id,
                         proposal=self.proposal,
                         rate=3)

    @unittest.skipIf(six.PY3, 'not test unicode on python3')
    def test_assert_proposal_unicode_representation(self):
        self.assertEquals(u'Python For Zombies', six.text_type(self.proposal))

    def test_assert_proposal_title(self):
        self.assertEquals(u'Python For Zombies', self.proposal.title)

    def test_assert_proposal_description(self):
        self.assertEquals(u'Brain...', self.proposal.description)

    def test_assert_proposal_author(self):
        self.assertEquals(1, self.proposal.author_id)

    def test_assert_proposal_rate(self):
        self.assertEquals(0, self.proposal.get_rate)

    def test_get_absolute_url(self):
        self.proposal.event = self.event
        self.assertEquals('/events/rupy/#python-for-zombies',
                          self.proposal.get_absolute_url())

    def test_assert_user_cannot_vote_multiple_times(self):
        self.event.save()
        self.proposal.event = self.event
        self.proposal.author = User.objects.get(id=2)
        self.proposal.save()
        self.vote.proposal = self.proposal
        self.vote.save()

        self.assertTrue(self.proposal.user_already_voted(self.user))

    def test_assert_proposal_is_published(self):
        self.assertEquals(True, self.proposal.is_published)

    def test_assert_proposal_approve(self):
        self.event.save()
        self.proposal.event = self.event
        self.proposal.save()

        self.assertEquals(False, self.proposal.is_approved)
        self.proposal.approve()
        self.assertEquals(True, self.proposal.is_approved)

    def test_assert_proposal_disapprove(self):
        self.event.save()
        self.proposal.event = self.event
        self.proposal.is_approved = True
        self.proposal.save()

        self.assertEquals(True, self.proposal.is_approved)
        self.proposal.disapprove()
        self.assertEquals(False, self.proposal.is_approved)
コード例 #7
0
ファイル: test_unit.py プロジェクト: digideskio/speakerfight
class ProposalObjectTest(TestCase):
    fixtures = ['user.json']

    def setUp(self):
        self.user = User.objects.first()
        self.event = Event(**EVENT_DATA)
        self.proposal = Proposal(**PROPOSAL_DATA)
        self.vote = Vote(user_id=self.event.author_id,
                         proposal=self.proposal, rate=3)

    def test_assert_proposal_unicode_representation(self):
        self.assertEquals(u'Python For Zombies', unicode(self.proposal))

    def test_assert_proposal_title(self):
        self.assertEquals(u'Python For Zombies', self.proposal.title)

    def test_assert_proposal_description(self):
        self.assertEquals(u'Brain...', self.proposal.description)

    def test_assert_proposal_author(self):
        self.assertEquals(1, self.proposal.author_id)

    def test_assert_proposal_rate(self):
        self.assertEquals(0, self.proposal.get_rate)

    def test_get_absolute_url(self):
        self.proposal.event = self.event
        self.assertEquals('/events/rupy/#python-for-zombies',
                          self.proposal.get_absolute_url())

    def test_assert_user_cannot_vote_multiple_times(self):
        self.event.save()
        self.proposal.event = self.event
        self.proposal.author = User.objects.get(id=2)
        self.proposal.save()
        self.vote.proposal = self.proposal
        self.vote.save()

        self.assertTrue(self.proposal.user_already_voted(self.user))

    def test_assert_proposal_is_published(self):
        self.assertEquals(True, self.proposal.is_published)

    def test_assert_proposal_approve(self):
        self.event.save()
        self.proposal.event = self.event
        self.proposal.save()

        self.assertEquals(False, self.proposal.is_approved)
        self.proposal.approve()
        self.assertEquals(True, self.proposal.is_approved)

    def test_assert_proposal_disapprove(self):
        self.event.save()
        self.proposal.event = self.event
        self.proposal.is_approved = True
        self.proposal.save()

        self.assertEquals(True, self.proposal.is_approved)
        self.proposal.disapprove()
        self.assertEquals(False, self.proposal.is_approved)

    def test_assert_proposal_get_authors_email(self):
        self.event.save()
        self.proposal.event = self.event
        self.proposal.save()
        self.assertEquals(self.proposal.authors_emails, [self.proposal.author.email])

    def test_assert_proposal_get_all_authors_email(self):
        self.event.save()
        self.proposal.event = self.event
        self.proposal.save()
        user = User.objects.get(id=2)
        self.proposal.coauthors.add(user.id)
        self.assertEquals(self.proposal.authors_emails, [self.proposal.author.email, user.email])

    def test_assert_proposal_should_have_coauthors_names(self):
        self.event.save()
        self.proposal.event = self.event
        self.proposal.save()
        coauthors_names = self.proposal.coauthors_names
        self.assertEquals(coauthors_names, "None")
        self.proposal.coauthors.add(2)
        self.proposal.coauthors.add(3)
        coauthors_names = self.proposal.coauthors_names
        self.assertEquals(coauthors_names, "user, another")