Exemplo n.º 1
0
    def setUp(self):
        self.country = Country(name='United States')
        self.country.save()
        self.region = Region(name='New York', country=self.country)
        self.region.save()

        self.city = City.objects.create(country=self.country,
                                        region=self.region,
                                        name='New York')
        self.city.save()

        self.family = Family.objects.create(
            family_name='Jenkins',
            address1='2042 Farnum Road',
            city=self.city,
            region=self.region,
            country=self.country,
            postal_code='10013',
        )
        self.family.save()
        self.member = Member.objects.create(family=self.family,
                                            first_name='John',
                                            gender='M',
                                            birth_date='1950-12-31')
        self.member.save()
Exemplo n.º 2
0
class FamilyModelTests(TestCase):
    def setUp(self):
        self.country = Country(name='United States')
        self.country.save()
        self.region = Region(name='New York', country=self.country)
        self.region.save()

        self.city = City.objects.create(country=self.country,
                                        region=self.region,
                                        name='New York')
        self.city.save()

        self.family = Family.objects.create(
            family_name='Jenkins',
            address1='2042 Farnum Road',
            city=self.city,
            region=self.region,
            country=self.country,
            postal_code='10013',
        )
        self.family.save()
        self.member = Member.objects.create(family=self.family,
                                            first_name='John',
                                            gender='M',
                                            birth_date='1950-12-31')
        self.member.save()

    def test_family_creation(self):
        now = timezone.now()
        self.assertLess(self.family.created_at, now)

    def test_member_creation(self):
        self.assertIn(self.member, self.family.member_set.all())
Exemplo n.º 3
0
    def setUp(self):
        self.country = Country(name='United States')
        self.country.save()

        self.region = Region(name='Tennessee', country=self.country)
        self.region.save()

        self.city = City.objects.create(country=self.country,
                                        region=self.region,
                                        name='Chattanooga')
        self.city.save()

        self.family = Family.objects.create(
            family_name='Doe',
            address1='239 Main Street',
            city=self.city,
            region=self.region,
            country=self.country,
            postal_code='37405',
        )
        self.family.save()
        self.member = Member.objects.create(
            family=self.family,
            first_name='James',
            last_name='Doepp',
            gender='M',
        )
        self.member.save()

        self.group_type = GroupType.objects.create(group_type='Sunday School')
        self.group_type.save()

        self.group = Group.objects.create(
            group_name='Kid\'s Praise',
            group_type=self.group_type,
            group_description='',
        )
        self.group.save()

        self.group_member = GroupMember.objects.create(member=self.member,
                                                       group=self.group)
        self.group_member.save()

        self.location = Location.objects.create(
            name='Room 101',
            building='Main building',
            description='No description necessary')
        self.location.save()
Exemplo n.º 4
0
class GroupTest(TestCase):
    def setUp(self):
        self.country = Country(name='United States')
        self.country.save()
        self.region = Region(name='New York', country=self.country)
        self.region.save()

        self.city = City.objects.create(country=self.country,
                                        region=self.region,
                                        name='New York')
        self.city.save()

        self.family = Family.objects.create(
            family_name='Jenkins',
            address1='2042 Farnum Road',
            city=self.city,
            region=self.region,
            country=self.country,
            postal_code='10013',
        )
        self.family.save()
        self.member = Member.objects.create(
            family=self.family,
            first_name='John',
            gender='M',
            birth_date='1950-12-31',
            fam_member_type='a',
        )
        self.member.save()
        self.group_type = GroupType.objects.create(group_type='Sunday School')
        self.group_type.save()
        self.group = Group.objects.create(
            group_name='Kid\'s Praise',
            group_type=self.group_type,
            group_description='',
        )
        self.group.save()

    def test_group_list_view(self):
        resp = self.client.get(reverse('groups:group_list'))
        #    self.assertEqual(resp.status_code, 200)
        #    self.assertIn(self.group, resp.context['groups'])
        #    self.assertTemplateUsed(resp, 'groups/group_list.html')
        #    self.assertContains(resp, self.group.group_name)
        print(resp)
Exemplo n.º 5
0
    def setUp(self):
        self.country = Country(name='United States')
        self.country.save()
        self.region = Region(name='New York', country=self.country)
        self.region.save()

        self.city = City.objects.create(country=self.country,
                                        region=self.region,
                                        name='New York')
        self.city.save()

        self.family = Family.objects.create(
            family_name='Jenkins',
            address1='2042 Farnum Road',
            city=self.city,
            region=self.region,
            country=self.country,
            postal_code='10013',
        )
        self.family.save()
        self.member = Member.objects.create(
            family=self.family,
            first_name='John',
            gender='M',
            birth_date='1950-12-31',
            fam_member_type='a',
        )
        self.member.save()
        self.group_type = GroupType.objects.create(group_type='Sunday School')
        self.group_type.save()
        self.group = Group.objects.create(
            group_name='Kid\'s Praise',
            group_type=self.group_type,
            group_description='',
        )
        self.group.save()
Exemplo n.º 6
0
class EventModelTests(TestCase):
    def setUp(self):
        self.country = Country(name='United States')
        self.country.save()

        self.region = Region(name='Tennessee', country=self.country)
        self.region.save()

        self.city = City.objects.create(country=self.country,
                                        region=self.region,
                                        name='Chattanooga')
        self.city.save()

        self.family = Family.objects.create(
            family_name='Doe',
            address1='239 Main Street',
            city=self.city,
            region=self.region,
            country=self.country,
            postal_code='37405',
        )
        self.family.save()
        self.member = Member.objects.create(
            family=self.family,
            first_name='James',
            last_name='Doepp',
            gender='M',
        )
        self.member.save()

        self.group_type = GroupType.objects.create(group_type='Sunday School')
        self.group_type.save()

        self.group = Group.objects.create(
            group_name='Kid\'s Praise',
            group_type=self.group_type,
            group_description='',
        )
        self.group.save()

        self.group_member = GroupMember.objects.create(member=self.member,
                                                       group=self.group)
        self.group_member.save()

        self.location = Location.objects.create(
            name='Room 101',
            building='Main building',
            description='No description necessary')
        self.location.save()

    def test_get_absolute_url(self):
        self.event = Event.objects.create(
            name='Kid\'s Praise',
            event_type='S',
            description='Children\'s Sunday school',
            creator=self.member,
            group=self.group,
            location=self.location)
        self.event.save()
        url = self.event.get_absolute_url()
        print(url)

    def test_add_occurences(self):
        self.event = Event.objects.create(
            name='Kid\'s Praise',
            event_type='M',
            description='Children\'s Sunday school',
            creator=self.member,
            group=self.group,
            location=self.location)
        self.event.save()

        tzinfo = pytz.utc
        dtstart = datetime(2018, 11, 24, 12, 30, 0, 0, tzinfo)
        until = datetime(2018, 12, 24, 12, 30, 0, 0, tzinfo)
        freq = 1
        duration = timedelta(hours=1, minutes=15)

        self.event.add_occurrences(duration, dtstart=dtstart, until=until)
        print(self.event.occurrence_set)
        occurrences = Occurrence.objects.filter(event=self.event)

        for occurence in occurrences:
            print(occurence.start_time, occurence.duration)
Exemplo n.º 7
0
class FamilyViewsTests(TestCase):
    def setUp(self):
        self.country = Country(name='United States')
        self.country.save()
        self.region = Region(name='New York', country=self.country)
        self.region.save()

        self.city = City.objects.create(country=self.country,
                                        region=self.region,
                                        name='New York')
        self.city.save()

        self.family = Family.objects.create(
            family_name='Jenkins',
            address1='2042 Farnum Road',
            city=self.city,
            region=self.region,
            country=self.country,
            postal_code='10013',
        )
        self.family.save()
        self.member = Member.objects.create(
            family=self.family,
            first_name='John',
            gender='M',
            birth_date='1950-12-31',
            fam_member_type='a',
        )
        self.member.save()
        self.family2 = Family.objects.create(
            family_name='Singh',
            address1='87 Shady Pines Drive',
            city=self.city,
            region=self.region,
            country=self.country,
            postal_code='24251',
        )
        self.family2.save()

    def test_family_list_view(self):
        resp = self.client.get(reverse('families:family_list'))
        self.assertEqual(resp.status_code, 200)
        self.assertIn(self.family, resp.context['families'])
        self.assertIn(self.family2, resp.context['families'])
        self.assertTemplateUsed(resp, 'families/family_list.html')
        self.assertContains(resp, self.family.family_name)

    def test_family_detail_view(self):
        resp = self.client.get(
            reverse('families:family_detail', kwargs={'pk': self.family.pk}))
        self.assertEqual(resp.status_code, 200)
        self.assertEqual(self.family, resp.context['family'])
        self.assertTemplateUsed(resp, 'families/family_detail.html')
        self.assertContains(resp, self.family.family_name)

    def test_member_detail_view(self):
        resp = self.client.get(
            reverse('families:member_detail',
                    kwargs={
                        'family_pk': self.family.pk,
                        'member_pk': self.member.pk,
                    }))
        self.assertEqual(resp.status_code, 200)
        self.assertTemplateUsed(resp, 'families/member_detail.html')
        self.assertContains(resp, self.member.last_name)