Esempio n. 1
0
class CommitteeMembersChairTest(TestCase):
    fixtures = ["members.json", "member_groups.json"]

    @classmethod
    def setUpTestData(cls):
        cls.testcie = Committee.objects.get(pk=1)
        cls.testuser = Member.objects.get(pk=1)
        cls.testuser2 = Member.objects.get(pk=2)

    def setUp(self):
        self.m1 = MemberGroupMembership(
            group=self.testcie,
            since=timezone.now().date().replace(day=1, year=1900),
            member=self.testuser,
            chair=True,
        )
        self.m1.full_clean()
        self.m1.save()

    def test_second_chair_fails(self):
        m = MemberGroupMembership(group=self.testcie, member=self.testuser2, chair=True)
        with self.assertRaises(ValidationError):
            m.full_clean()

    def test_inactive_chair(self):
        self.m1.until = timezone.now().date().replace(day=1, year=1900)
        self.m1.save()

        m = MemberGroupMembership(group=self.testcie, member=self.testuser2, chair=True)
        m.full_clean()

    def test_clean_self_chair(self):
        self.m1.chair = True
        self.m1.full_clean()
Esempio n. 2
0
    def test_join_unique_period(self):
        m1 = MemberGroupMembership(
            group=self.testcie,
            member=self.testuser,
            since=timezone.now().date().replace(year=2014, month=1, day=1),
            until=timezone.now().date().replace(year=2014, month=3, day=1),
        )
        m1.save()

        m2 = MemberGroupMembership(
            group=self.testcie,
            member=self.testuser,
            since=timezone.now().date().replace(year=2014, month=1, day=1),
            until=timezone.now().date().replace(year=2014, month=2, day=1),
        )
        with self.assertRaises(ValidationError):
            m2.full_clean()
Esempio n. 3
0
    def create_member_group_membership(self, member, group):
        """
        Create member group membership

        :param member: the member to add to the committee
        :param group: the group to add the member to
        """
        membership = MemberGroupMembership()

        membership.member = member
        membership.group = group

        today = date.today()
        month = timedelta(days=30)
        membership.since = _faker.date_time_between_dates(
            group.since, today + month).date()

        if random.random() < 0.2 and membership.since < today:
            membership.until = _faker.date_time_between_dates(
                membership.since, today).date()

        membership.save()
Esempio n. 4
0
 def test_join(self):
     testuser2 = Member.objects.get(pk=2)
     m = MemberGroupMembership(group=self.testcie, member=testuser2)
     m.full_clean()
     m.save()