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')
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)
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)
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)
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)
def test_ballot_delete(self): """ Tests Ballot model delete """ model = BallotF.create() model.delete() # check if deleted self.assertTrue(model.pk is None)
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 }))
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 }))
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)
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)
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)
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)
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}), )
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')