Esempio n. 1
0
    def test_invalid_cases(self):
        """Invalid cases shouldn't be triggered
        """
        person = get_person_case_structure(self.person_id, self.user.user_id)

        occurrence = get_occurrence_case_structure(self.occurrence_id, person)

        episode_structure = get_episode_case_structure(self.episode_id, occurrence)
        self.factory.create_or_update_case(episode_structure)

        archived_person = get_person_case_structure("person_2", self.user.user_id, owner_id="_archive_")
        occurrence = get_occurrence_case_structure('occurrence_2', archived_person)
        invalid_episode_structure = get_episode_case_structure('episode_2', occurrence)
        self.factory.create_or_update_case(invalid_episode_structure)

        closed_person = get_person_case_structure("person_3", self.user.user_id)
        occurrence = get_occurrence_case_structure('occurrence_3', closed_person)
        closed_episode_structure = get_episode_case_structure('episode_3', occurrence)
        self.factory.create_or_update_case(closed_episode_structure)
        self.factory.create_or_update_case(CaseStructure(
            case_id="person_3",
            attrs={'close': True}
        ))
        case_ids = [
            item for batch in self.case_updater._get_case_id_batches()
            for item in batch
        ]
        episode_ids = [episode.case_id
                       for episode in self.case_updater._get_open_episode_cases(case_ids)]
        self.assertEqual(episode_ids, [self.episode_id])
    def _create_episode_case(
        self,
        adherence_schedule_date_start=None,
        adherence_schedule_id=None,
        extra_properties=None,
    ):
        person = get_person_case_structure(
            self.person_id,
            self.user.user_id,
        )

        occurrence = get_occurrence_case_structure(self.occurrence_id, person)

        extra_update = {
            'adherence_schedule_date_start': adherence_schedule_date_start,
            'adherence_schedule_id': adherence_schedule_id
        }
        extra_update.update(extra_properties or {})

        episode_structure = get_episode_case_structure(
            self.episode_id,
            occurrence,
            extra_update=extra_update,
        )
        cases = {
            case.case_id: case
            for case in self.factory.create_or_update_cases(
                [episode_structure])
        }
Esempio n. 3
0
    def _setup_casedata(cls):
        cls.episode_id = "episode"
        factory = CaseFactory(domain=cls.domain)

        person = get_person_case_structure(
            "person",
            cls.user.user_id,
        )

        occurrence = get_occurrence_case_structure("occurence", person)

        episode_structure = get_episode_case_structure(cls.episode_id,
                                                       occurrence)

        cases = {
            case.case_id: case
            for case in factory.create_or_update_cases([episode_structure])
        }
Esempio n. 4
0
 def _get_occurrence_structure(self, person):
     case_id = person.case_id + '-occurrence'
     return get_occurrence_case_structure(case_id, person)