def setUp(self):

        self.family = Family()
        self.family.save()
Beispiel #2
0
    def setUp(self):

        self.family = Family()
        self.family.save()

        super(PersonTestCase, self).setUp()
Beispiel #3
0
    def setUp(self):
        self.family = Family()
        self.family.save()

        self.family2 = Family()
        self.family2.save()

        self.user = User.objects.create_user(email='*****@*****.**',
                                             password='******',
                                             name='Edith Clarke',
                                             family=self.family)

        self.person1 = Person(name='Edith Clarke',
                              gender='F',
                              email='*****@*****.**',
                              family_id=self.family.id,
                              language='en',
                              user_id=self.user.id)
        self.person1.save()

        self.person2 = Person(name='someone else',
                              gender='O',
                              email='*****@*****.**',
                              family_id=self.family.id,
                              language='en',
                              user_id=self.user.id)
        self.person2.save()

        self.person3 = Person(name='another person',
                              gender='O',
                              email='*****@*****.**',
                              family_id=self.family.id,
                              language='en',
                              user_id=self.user.id)
        self.person3.save()

        self.relation1 = Relation.objects.create(from_person=self.person1,
                                                 to_person=self.person2,
                                                 relation_type=PARTNERED)
        self.relation1.save()

        self.relation2 = Relation.objects.create(from_person=self.person1,
                                                 to_person=self.person3,
                                                 relation_type=RAISED)
        self.relation2.save()

        self.otherFamilyUser = User.objects.create_user(
            email='*****@*****.**',
            password='******',
            name='Another Family',
            family=self.family2)

        self.otherFamilyPerson = Person(name='another family',
                                        gender='O',
                                        email='*****@*****.**',
                                        family_id=self.family2.id,
                                        language='en',
                                        user_id=self.user.id)
        self.otherFamilyPerson.save()

        self.otherFamilyPerson2 = Person(name='another family 2',
                                         gender='O',
                                         email='*****@*****.**',
                                         family_id=self.family2.id,
                                         language='en',
                                         user_id=self.user.id)
        self.otherFamilyPerson2.save()

        self.relation3 = Relation.objects.create(
            from_person=self.otherFamilyPerson,
            to_person=self.otherFamilyPerson2,
            relation_type=PARTNERED)
        self.relation3.save()

        super(RelationApiTestCase, self).setUp()
Beispiel #4
0
    def test_get_relation_name(self):
        family = Family()
        family.save()

        user = User.objects.create_user(email='*****@*****.**',
                                        password='******',
                                        name='Margaret Knight',
                                        family=family)

        person = Person.objects.create(name='patient zero',
                                       gender='M',
                                       family_id=family.id)

        wife = Person.objects.create(name='wife',
                                     gender='F',
                                     family_id=family.id)
        Relation.objects.create(from_person=wife,
                                to_person=person,
                                relation_type=PARTNERED)

        son = Person.objects.create(name='son',
                                    gender='M',
                                    family_id=family.id)
        Relation.objects.create(from_person=person,
                                to_person=son,
                                relation_type=RAISED)

        daughter = Person.objects.create(name='daughter',
                                         gender='F',
                                         family_id=family.id)
        Relation.objects.create(from_person=person,
                                to_person=daughter,
                                relation_type=RAISED)

        mum = Person.objects.create(name='mum',
                                    gender='F',
                                    family_id=family.id)
        Relation.objects.create(from_person=mum,
                                to_person=person,
                                relation_type=RAISED)

        dad = Person.objects.create(name='dad',
                                    gender='M',
                                    family_id=family.id)
        Relation.objects.create(from_person=dad,
                                to_person=person,
                                relation_type=RAISED)

        grandma = Person.objects.create(name='grandma',
                                        gender='F',
                                        family_id=family.id)
        Relation.objects.create(from_person=grandma,
                                to_person=mum,
                                relation_type=RAISED)

        grandson = Person.objects.create(name='grandson',
                                         gender='M',
                                         family_id=family.id)
        Relation.objects.create(from_person=son,
                                to_person=grandson,
                                relation_type=RAISED)

        client = APIClient(HTTP_X_REAL_IP='127.0.0.1')
        client.force_authenticate(user=user)
        url = '/api/relation_name/{0}/{1}/'.format(person.id, grandson.id)
        response = client.get(url, format='json')

        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertTrue(b"syun1" in response.content)
Beispiel #5
0
    def setUp(self):

        self.family = Family()
        self.family.save()

        self.user = User.objects.create_user(email='*****@*****.**',
                                             password='******',
                                             name='Phil Collins',
                                             family=self.family)

        self.person = Person(name='Phil Collins',
                             gender='M',
                             email='*****@*****.**',
                             family_id=self.family.id,
                             language='en',
                             user_id=self.user.id)
        self.person.save()

        self.gallery = Gallery.objects.create(title="test_gallery",
                                              family_id=self.family.id)
        self.test_image = os.path.join(settings.BASE_DIR,
                                       'gallery/tests/test_image.jpg')
        self.test_image_destination = ''.join([
            settings.MEDIA_ROOT, 'galleries/',
            str(self.family.id), '/',
            str(self.gallery.id), '/test_image.jpg'
        ])

        directory = ''.join([
            settings.MEDIA_ROOT, 'galleries/',
            str(self.family.id), '/',
            str(self.gallery.id)
        ])
        if not os.path.exists(directory):
            os.makedirs(directory)

        #Copy test image to media area
        shutil.copy2(self.test_image, self.test_image_destination)

        self.image = Image(gallery=self.gallery,
                           family=self.family,
                           original_image=''.join([
                               'galleries/',
                               str(self.family.id), '/',
                               str(self.gallery.id), '/test_image.jpg'
                           ]))
        self.image.save()

        #Tag person 1 in image
        self.tag = Tag.objects.create(image=self.image,
                                      person=self.person,
                                      x1=1,
                                      x2=2,
                                      y1=3,
                                      y2=4)

        self.gallery2 = Gallery.objects.create(title="test_gallery2",
                                               family_id=self.family.id)
        self.test_image2 = os.path.join(settings.BASE_DIR,
                                        'gallery/tests/test_image.jpg')
        self.test_image2_destination = ''.join([
            settings.MEDIA_ROOT, 'galleries/',
            str(self.family.id), '/',
            str(self.gallery2.id), '/test_image.jpg'
        ])

        directory = ''.join([
            settings.MEDIA_ROOT, 'galleries/',
            str(self.family.id), '/',
            str(self.gallery2.id)
        ])
        if not os.path.exists(directory):
            os.makedirs(directory)

        #Copy test image to media area
        shutil.copy2(self.test_image2, self.test_image2_destination)

        self.image2 = Image(gallery=self.gallery2,
                            family=self.family,
                            original_image=''.join([
                                'galleries/',
                                str(self.family.id), '/',
                                str(self.gallery2.id), '/test_image.jpg'
                            ]))
        self.image2.save()

        self.family2 = Family()
        self.family2.save()

        self.user2 = User.objects.create_user(
            email='*****@*****.**',
            password='******',
            name='Phillip Bailey',
            family=self.family2)

        self.person2 = Person(name='Phillip Bailey',
                              gender='M',
                              email='*****@*****.**',
                              family_id=self.family2.id,
                              language='en',
                              user_id=self.user2.id)
        self.person2.save()

        super(ImageApiTestCase, self).setUp()