Beispiel #1
0
 def setUp(self):
     self.test_committee = AbakusGroup.objects.get(name='Webkom')
     self.test_user = User.objects.get(pk=1)
     self.test_membership = Membership(user=self.test_user,
                                       abakus_group=self.test_committee,
                                       role=constants.TREASURER)
     self.test_membership.save()
Beispiel #2
0
class MembershipTestCase(BaseTestCase):
    fixtures = ["test_abakus_groups.yaml", "test_users.yaml"]

    def setUp(self):
        self.test_committee = AbakusGroup.objects.get(name="Webkom")
        self.test_user = User.objects.get(pk=1)
        self.test_membership = Membership(
            user=self.test_user,
            abakus_group=self.test_committee,
            role=constants.TREASURER,
        )
        self.test_membership.save()

    def test_to_string(self):
        self.assertEqual(
            str(self.test_membership),
            "{0} is {1} in {2}".format(
                self.test_membership.user,
                self.test_membership.get_role_display(),
                self.test_membership.abakus_group,
            ),
        )

    def test_natural_key(self):
        found_membership = Membership.objects.get_by_natural_key(
            self.test_user.username, self.test_committee.name
        )
        self.assertEqual(self.test_membership, found_membership)