コード例 #1
0
ファイル: test_models.py プロジェクト: cchristelis/projecta
    def test_ballot_read(self):
        """Tests Ballot model read."""
        model = BallotF.create(
            name=u'Custom Ballot'
        )

        self.assertTrue(model.name == 'Custom Ballot')
        self.assertTrue(model.slug == 'custom-ballot')
コード例 #2
0
 def setUp(self):
     """
     Setup before each test
     """
     logging.disable(logging.CRITICAL)
     self.user = UserF.create(**{"username": "******", "password": "******", "is_staff": True})
     self.project = ProjectF.create()
     self.committee = CommitteeF.create(project=self.project, users=[self.user])
     self.ballot = BallotF.create(committee=self.committee)
コード例 #3
0
ファイル: test_models.py プロジェクト: cchristelis/projecta
    def test_ballot_create(self):
        """Tests Ballot model creation."""
        model = BallotF.create()

        # check if PK exists
        self.assertTrue(model.pk is not None)

        # check if name exists
        self.assertTrue(model.name is not None)
コード例 #4
0
 def test_BallotDelete_no_login(self):
     client = Client()
     ballot_to_delete = BallotF.create(committee=self.committee)
     response = client.post(reverse('ballot-delete', kwargs={
         'slug': ballot_to_delete.slug,
         'committee_slug': ballot_to_delete.committee.slug,
         'project_slug': self.committee.project.slug
     }))
     self.assertEqual(response.status_code, 302)
コード例 #5
0
ファイル: test_views.py プロジェクト: gitter-badger/projecta
 def test_BallotDelete_no_login(self):
     my_client = Client()
     ballot_to_delete = BallotF.create(committee=self.my_committee)
     response = my_client.post(reverse('ballot-delete', kwargs={
         'slug': ballot_to_delete.slug,
         'committee_slug': ballot_to_delete.committee.slug,
         'project_slug': self.my_committee.project.slug
     }))
     self.assertEqual(response.status_code, 302)
コード例 #6
0
    def test_ballot_create(self):
        """Tests Ballot model creation."""
        model = BallotF.create()

        # check if PK exists
        self.assertTrue(model.pk is not None)

        # check if name exists
        self.assertTrue(model.name is not None)
コード例 #7
0
ファイル: test_models.py プロジェクト: cchristelis/projecta
    def test_ballot_delete(self):
        """
        Tests Ballot model delete
        """
        model = BallotF.create()

        model.delete()

        # check if deleted
        self.assertTrue(model.pk is None)
コード例 #8
0
    def test_ballot_delete(self):
        """
        Tests Ballot model delete
        """
        model = BallotF.create()

        model.delete()

        # check if deleted
        self.assertTrue(model.pk is None)
コード例 #9
0
ファイル: test_views.py プロジェクト: gitter-badger/projecta
 def test_BallotDelete_with_login(self):
     my_client = Client()
     ballot_to_delete = BallotF.create(committee=self.my_committee)
     my_client.login(username='******', password='******')
     response = my_client.post(reverse('ballot-delete', kwargs={
         'slug': ballot_to_delete.slug,
         'committee_slug': ballot_to_delete.committee.slug,
         'project_slug': ballot_to_delete.committee.project.slug
     }), {})
     self.assertRedirects(response, reverse('committee-detail', kwargs={
         'slug': self.my_committee.slug,
         'project_slug': self.my_project.slug
     }))
コード例 #10
0
 def test_BallotDelete_with_login(self):
     client = Client()
     ballot_to_delete = BallotF.create(committee=self.committee)
     client.login(username='******', password='******')
     response = client.post(reverse('ballot-delete', kwargs={
         'slug': ballot_to_delete.slug,
         'committee_slug': ballot_to_delete.committee.slug,
         'project_slug': ballot_to_delete.committee.project.slug
     }), {})
     self.assertRedirects(response, reverse('committee-detail', kwargs={
         'slug': self.committee.slug,
         'project_slug': self.project.slug
     }))
コード例 #11
0
 def setUp(self):
     """
     Setup before each test
     """
     logging.disable(logging.CRITICAL)
     self.user = UserF.create(**{
         'username': '******',
         'password': '******',
         'is_staff': True
     })
     self.project = ProjectF.create()
     self.committee = CommitteeF.create(project=self.project,
                                          users=[self.user])
     self.ballot = BallotF.create(committee=self.committee)
コード例 #12
0
 def test_BallotDelete_no_login(self):
     client = Client()
     ballot_to_delete = BallotF.create(committee=self.committee)
     response = client.post(
         reverse(
             "ballot-delete",
             kwargs={
                 "slug": ballot_to_delete.slug,
                 "committee_slug": ballot_to_delete.committee.slug,
                 "project_slug": self.committee.project.slug,
             },
         )
     )
     self.assertEqual(response.status_code, 302)
コード例 #13
0
ファイル: test_views.py プロジェクト: gitter-badger/projecta
 def setUp(self):
     """
     Setup before each test
     """
     logging.disable(logging.CRITICAL)
     self.my_user = UserF.create(**{
         'username': '******',
         'password': '******',
         'is_staff': True
     })
     self.my_project = ProjectF.create()
     self.my_committee = CommitteeF.create(project=self.my_project,
                                          users=[self.my_user])
     self.my_ballot = BallotF.create(committee=self.my_committee)
コード例 #14
0
    def test_ballot_update(self):
        """Tests Ballot model update."""
        model = BallotF.create()
        new_model_data = {
            'name': u'New Ballot Name',
            'summary': u'New summary',
            'description': u'This is a great description',
            'approved': False,
            'no_quorum': True,
        }
        model.__dict__.update(new_model_data)
        model.save()

        # check if updated
        for key, val in new_model_data.items():
            self.assertEqual(model.__dict__.get(key), val)
コード例 #15
0
ファイル: test_models.py プロジェクト: cchristelis/projecta
    def test_ballot_update(self):
        """Tests Ballot model update."""
        model = BallotF.create()
        new_model_data = {
            'name': u'New Ballot Name',
            'summary': u'New summary',
            'description': u'This is a great description',
            'approved': False,
            'no_quorum': True,
        }
        model.__dict__.update(new_model_data)
        model.save()

        # check if updated
        for key, val in new_model_data.items():
            self.assertEqual(model.__dict__.get(key), val)
コード例 #16
0
 def test_BallotDelete_with_login(self):
     client = Client()
     ballot_to_delete = BallotF.create(committee=self.committee)
     client.login(username="******", password="******")
     response = client.post(
         reverse(
             "ballot-delete",
             kwargs={
                 "slug": ballot_to_delete.slug,
                 "committee_slug": ballot_to_delete.committee.slug,
                 "project_slug": ballot_to_delete.committee.project.slug,
             },
         ),
         {},
     )
     self.assertRedirects(
         response,
         reverse("committee-detail", kwargs={"slug": self.committee.slug, "project_slug": self.project.slug}),
     )
コード例 #17
0
    def test_ballot_read(self):
        """Tests Ballot model read."""
        model = BallotF.create(name=u'Custom Ballot')

        self.assertTrue(model.name == 'Custom Ballot')
        self.assertTrue(model.slug == 'custom-ballot')