def setUpClass(cls):
     cls.manager = get_db_manager('http://localhost:5984/',
                                  uniq('mangrove-test'))
     initializer._create_views(cls.manager)
     cls.entity_type = ["HealthFacility", "Clinic"]
     safe_define_type(cls.manager, ["HealthFacility", "Clinic"])
     cls._create_form_model()
示例#2
0
    def setUpClass(cls):
        cls.dbm = create_db(uniq('mangrove-test'))
        initializer.initial_data_setup(cls.dbm)
        cls.entity_type = ["healthfacility", "clinic"]
        safe_define_type(cls.dbm, cls.entity_type)

        cls.entity_short_code = "cli" + str(int(random.random() * 10000))
        cls.entity = create_entity(
            cls.dbm,
            entity_type=cls.entity_type,
            location=["India", "Pune"],
            aggregation_paths=None,
            short_code=cls.entity_short_code,
        )
        cls.entity.save()
        cls.reporter_id = "rep" + str(int(random.random() * 10000))
        cls.reporter = create_contact(cls.dbm,
                                      location=["India", "Pune"],
                                      aggregation_paths=None,
                                      short_code=cls.reporter_id)
        cls.reporter.save()

        cls.phone_number = str(int(random.random() * 10000000))
        cls.reporter.add_data(data=[(MOBILE_NUMBER_FIELD, cls.phone_number),
                                    (NAME_FIELD, "Test_reporter")],
                              submission=dict(submission_id="2"))

        question1 = ShortCodeField(
            name="entity_question",
            code="EID",
            label="What is associated entity",
            constraints=[TextLengthConstraint(min=1, max=20)])
        question2 = TextField(name="Name",
                              code="NAME",
                              label="Clinic Name",
                              defaultValue="some default value",
                              constraints=[TextLengthConstraint(4, 15)],
                              required=False)
        question3 = IntegerField(
            name="Arv stock",
            code="ARV",
            label="ARV Stock",
            constraints=[NumericRangeConstraint(min=15, max=120)],
            required=False)
        question4 = SelectField(name="Color",
                                code="COL",
                                label="Color",
                                options=[("RED", 'a'), ("YELLOW", 'a')],
                                required=False)

        try:
            cls.form_model = get_form_model_by_code(cls.dbm, "clinic")
        except FormModelDoesNotExistsException:
            cls.form_model = EntityFormModel(
                cls.dbm,
                entity_type=cls.entity_type,
                name="aids",
                label="Aids form_model",
                form_code="clinic",
                fields=[question1, question2, question3],
                is_registration_model=True)
            cls.form_model.add_field(question4)
            cls.form_model.save()
        cls.sms_player = SMSPlayer(cls.dbm, LocationTree())
        cls.sms_ordered_message_player = SMSPlayer(cls.dbm, LocationTree())
 def _create_default_dd_type(cls):
     cls.entity_type = ["HealthFacility", "Clinic"]
     safe_define_type(cls.manager, ["HealthFacility", "Clinic"])
     cls.default_ddtype = get_or_create_data_dict(
         cls.manager, 'Default String Datadict Type', 'string_default',
         'string')
示例#4
0
 def create_water_point_entity(self):
     water_point_type = ["waterpoint"]
     safe_define_type(self.manager, water_point_type)
     create_entity(self.manager, entity_type=water_point_type, short_code=uniq("4"))
示例#5
0
 def create_clinic_type(self, entity_type):
     self.entity_type = entity_type
     safe_define_type(self.manager, entity_type)
示例#6
0
 def setUpClass(cls):
     create_dbmanager_for_ut(cls)
     safe_define_type(cls.manager, [REPORTER])
     cls.reg_form = delete_and_create_form_model(
         cls.manager, GLOBAL_REGISTRATION_FORM_CODE)