Esempio n. 1
0
 def given_a_profile_repo_that_returns_on_get(self, profile):
     if profile is False:
         self.profile_repo.get_profile.side_effect = EntityDoesNotExistException(
         )
     else:
         self.profile_repo.get_profile.return_value = profile
     return self
Esempio n. 2
0
 def given_a_person_repo_that_returns_on_get(self, person):
     if person is False:
         self.person_repo.get_person.side_effect = EntityDoesNotExistException(
         )
     else:
         self.person_repo.get_person.return_value = person
     return self
Esempio n. 3
0
    def attach_picture_to_experience(self, experience_id, picture):
        try:
            experience = ORMExperience.objects \
                                        .exclude(is_deleted=True) \
                                        .get(id=experience_id)
        except ORMExperience.DoesNotExist:
            raise EntityDoesNotExistException()

        experience.picture = picture
        experience.save()
        return self._decode_db_experience(experience, str(experience.author_id))
Esempio n. 4
0
 def get_experience(self, id=None, share_id=None, logged_person_id=None):
     try:
         if id is not None:
             db_experience = ORMExperience.objects \
                                             .exclude(is_deleted=True) \
                                             .select_related('author__profile').get(id=id)
         else:
             db_experience = ORMExperience.objects \
                                             .exclude(is_deleted=True) \
                                             .select_related('author__profile').get(share_id=share_id)
         is_mine = (logged_person_id == db_experience.author_id)
         is_saved = False
         if logged_person_id is not None and not is_mine:
             is_saved = ORMSave.objects.filter(experience_id=id, person_id=logged_person_id).exists()
         return self._decode_db_experience(db_experience, logged_person_id, is_saved=is_saved)
     except ORMExperience.DoesNotExist:
         raise EntityDoesNotExistException()
Esempio n. 5
0
    def update_experience(self, experience, logged_person_id=None):
        try:
            orm_experience = ORMExperience.objects \
                                            .exclude(is_deleted=True) \
                                            .get(id=experience.id)
        except ORMExperience.DoesNotExist:
            raise EntityDoesNotExistException()

        orm_experience.title = experience.title
        orm_experience.description = experience.description
        orm_experience.share_id = experience.share_id

        try:
            orm_experience.save()
        except IntegrityError:
            raise ConflictException(source='share_id', code='duplicate', message='Duplicate share_id')
        return self._decode_db_experience(orm_experience, logged_person_id)
Esempio n. 6
0
 def raiser_func():
     raise EntityDoesNotExistException()
Esempio n. 7
0
 def fake_get_person(email=None):
     if email is not None:
         return self.second_person
     raise EntityDoesNotExistException()
Esempio n. 8
0
 def given_a_person_repo_that_raises_entity_does_not_exist(self):
     self.person_repo.get_person.side_effect = EntityDoesNotExistException(
     )
     return self
Esempio n. 9
0
 def fake_get_profile(username=None, logged_person_id=None):
     if username is not None and logged_person_id is not None:
         return self.second_profile
     raise EntityDoesNotExistException()
Esempio n. 10
0
 def given_an_scene_repo_that_raises_entity_does_not_exist(self):
     self.scene_repo = Mock()
     self.scene_repo.get_scene.side_effect = EntityDoesNotExistException(
     )
     return self
Esempio n. 11
0
 def given_an_unexistent_experience(self):
     self._experience_repo.get_experience.side_effect = EntityDoesNotExistException(
     )
     return self