예제 #1
0
    def setUpClass(cls):
        from casexml.apps.case.tests.util import delete_all_xforms
        delete_all_xforms()
        cls.domain = 'evelyn'
        cls.now = datetime.datetime.utcnow()
        cls.user_id1 = 'xzy'
        cls.user_id2 = 'abc'

        metadata1 = TestFormMetadata(
            domain=cls.domain,
            user_id=cls.user_id1,
            received_on=cls.now - datetime.timedelta(days=10),
        )
        metadata2 = TestFormMetadata(
            domain=cls.domain,
            user_id=cls.user_id2,
            received_on=cls.now,
        )

        xform1 = get_simple_wrapped_form('123', metadata=metadata1)
        xform2 = get_simple_wrapped_form('456', metadata=metadata2)

        xform_error = get_simple_wrapped_form('789', metadata=metadata2)
        xform_error = XFormError.wrap(xform_error.to_json())
        xform_error.save()

        cls.xform_deleted = get_simple_wrapped_form('101', metadata=metadata2)
        cls.xform_deleted.doc_type += '-Deleted'
        cls.xform_deleted.save()

        cls.xforms = [
            xform1,
            xform2,
        ]
        cls.xform_errors = [xform_error]
예제 #2
0
 def tearDown(self):
     self.adapter.clear_table()
     delete_all_cases()
     delete_all_xforms()
     InvalidUCRData.objects.all().delete()
     self.config.validations = []
     self.config.save()
예제 #3
0
    def setUpClass(cls):
        from casexml.apps.case.tests.util import delete_all_xforms

        delete_all_xforms()
        cls.now = datetime.datetime.utcnow()
        cls._60_days = datetime.timedelta(days=60)
        cls.domain = "my_crazy_analytics_domain"
        cls.app_id = uuid.uuid4().hex
        cls.xmlns = "my://crazy.xmlns/"
        cls.user_id = uuid.uuid4().hex
        cls.forms = [
            XFormInstance(
                domain=cls.domain,
                received_on=cls.now,
                app_id=cls.app_id,
                xmlns=cls.xmlns,
                form={"meta": {"userID": cls.user_id, "username": "******"}},
            ),
            XFormInstance(
                domain=cls.domain,
                received_on=cls.now - cls._60_days,
                app_id=cls.app_id,
                xmlns=cls.xmlns,
                form={"meta": {"userID": cls.user_id, "username": "******"}},
            ),
        ]
        cls.error_forms = [XFormError(domain=cls.domain)]
        cls.all_forms = cls.forms + cls.error_forms
        for form in cls.all_forms:
            form.save()

        update_analytics_indexes()
예제 #4
0
    def setUpClass(cls):
        from casexml.apps.case.tests.util import delete_all_xforms
        delete_all_xforms()
        cls.now = datetime.datetime.utcnow()
        cls._60_days = datetime.timedelta(days=60)
        cls.domain = 'my_crazy_analytics_domain'
        cls.app_id = uuid.uuid4().hex
        cls.xmlns = 'my://crazy.xmlns/'
        cls.user_id = uuid.uuid4().hex
        cls.forms = [
            XFormInstance(
                domain=cls.domain,
                received_on=cls.now,
                app_id=cls.app_id,
                xmlns=cls.xmlns,
                form={'meta': {
                    'userID': cls.user_id,
                    'username': '******'
                }}),
            XFormInstance(
                domain=cls.domain,
                received_on=cls.now - cls._60_days,
                app_id=cls.app_id,
                xmlns=cls.xmlns,
                form={'meta': {
                    'userID': cls.user_id,
                    'username': '******'
                }}),
        ]
        cls.error_forms = [XFormError(domain=cls.domain)]
        cls.all_forms = cls.forms + cls.error_forms
        for form in cls.all_forms:
            form.save()

        update_analytics_indexes()
예제 #5
0
 def tearDown(self):
     self.domain_obj.delete()
     delete_all_xforms()
     delete_all_ledgers()
     StockReport.objects.all().delete()
     StockTransaction.objects.all().delete()
     super(TestGetValuesByProduct, self).tearDown()
예제 #6
0
    def setUpClass(cls):
        @patch('couchforms.analytics.FormES.index', XFORM_INDEX_INFO.index)
        @patch('corehq.apps.es.es_query.ES_META', TEST_ES_META)
        @patch('corehq.elastic.ES_META', TEST_ES_META)
        def create_form_and_sync_to_es(received_on):
            with process_kafka_changes('XFormToElasticsearchPillow'):
                with process_couch_changes('DefaultChangeFeedPillow'):
                    metadata = TestFormMetadata(domain=cls.domain, app_id=cls.app_id,
                                                xmlns=cls.xmlns, received_on=received_on)
                    form = get_form_ready_to_save(metadata, is_db_test=True)
                    form_processor = FormProcessorInterface(domain=cls.domain)
                    form_processor.save_processed_models([form])
            return form

        from casexml.apps.case.tests.util import delete_all_xforms
        delete_all_xforms()
        cls.now = datetime.datetime.utcnow()
        cls._60_days = datetime.timedelta(days=60)
        cls.domain = 'my_crazy_analytics_domain'
        cls.app_id = uuid.uuid4().hex
        cls.xmlns = 'my://crazy.xmlns/'
        with trap_extra_setup(ConnectionError):
            cls.elasticsearch = get_es_new()
            initialize_index_and_mapping(cls.elasticsearch, XFORM_INDEX_INFO)
            cls.forms = [create_form_and_sync_to_es(cls.now), create_form_and_sync_to_es(cls.now-cls._60_days)]

        cls.elasticsearch.indices.refresh(XFORM_INDEX_INFO.index)
예제 #7
0
 def tearDown(self):
     delete_all_cases()
     delete_all_xforms()
     AsyncIndicator.objects.all().delete()
     InvalidUCRData.objects.all().delete()
     self.config.validations = []
     self.config.save()
예제 #8
0
 def tearDown(self):
     self.domain_obj.delete()
     delete_all_xforms()
     delete_all_ledgers()
     StockReport.objects.all().delete()
     StockTransaction.objects.all().delete()
     super(TestGetValuesByProduct, self).tearDown()
예제 #9
0
 def tearDown(self):
     self.adapter.clear_table()
     delete_all_cases()
     delete_all_xforms()
     InvalidUCRData.objects.all().delete()
     self.config.validations = []
     self.config.save()
예제 #10
0
    def setUpClass(cls):
        from casexml.apps.case.tests.util import delete_all_xforms
        from corehq.apps.app_manager.models import Application, Module, Form
        delete_all_xforms()
        cls.domain = 'exports_forms_analytics_domain'
        cls.app_id_1 = 'a' + uuid.uuid4().hex
        cls.app_id_2 = 'b' + uuid.uuid4().hex
        cls.xmlns_1 = 'my://crazy.xmlns/'
        cls.xmlns_2 = 'my://crazy.xmlns/app'
        cls.apps = [
            Application(_id=cls.app_id_2, domain=cls.domain,
                        modules=[Module(forms=[Form(xmlns=cls.xmlns_2)])])
        ]
        for app in cls.apps:
            app.save()
        cls.forms = [
            XFormInstance(domain=cls.domain,
                          app_id=cls.app_id_1, xmlns=cls.xmlns_1),
            XFormInstance(domain=cls.domain,
                          app_id=cls.app_id_1, xmlns=cls.xmlns_1),
            XFormInstance(domain=cls.domain,
                          app_id=cls.app_id_2, xmlns=cls.xmlns_2),
        ]
        cls.error_forms = [XFormError(domain=cls.domain)]
        cls.all_forms = cls.forms + cls.error_forms
        for form in cls.all_forms:
            form.save()

        update_analytics_indexes()
예제 #11
0
 def tearDown(self):
     delete_all_cases()
     delete_all_xforms()
     AsyncIndicator.objects.all().delete()
     InvalidUCRData.objects.all().delete()
     self.config.validations = []
     self.config.save()
예제 #12
0
    def setUpClass(cls):
        super(CouchformsESAnalyticsTest, cls).setUpClass()

        @patch('couchforms.analytics.FormES.index', XFORM_INDEX_INFO.index)
        @patch('corehq.apps.es.es_query.ES_META', TEST_ES_META)
        @patch('corehq.elastic.ES_META', TEST_ES_META)
        def create_form_and_sync_to_es(received_on):
            with process_pillow_changes('xform-pillow', {'skip_ucr': True}):
                with process_pillow_changes('DefaultChangeFeedPillow'):
                    metadata = TestFormMetadata(domain=cls.domain,
                                                app_id=cls.app_id,
                                                xmlns=cls.xmlns,
                                                received_on=received_on)
                    form = get_form_ready_to_save(metadata, is_db_test=True)
                    form_processor = FormProcessorInterface(domain=cls.domain)
                    form_processor.save_processed_models([form])
            return form

        from casexml.apps.case.tests.util import delete_all_xforms
        delete_all_xforms()
        cls.now = datetime.datetime.utcnow()
        cls._60_days = datetime.timedelta(days=60)
        cls.domain = 'my_crazy_analytics_domain'
        cls.app_id = uuid.uuid4().hex
        cls.xmlns = 'my://crazy.xmlns/'
        with trap_extra_setup(ConnectionError):
            cls.elasticsearch = get_es_new()
            initialize_index_and_mapping(cls.elasticsearch, XFORM_INDEX_INFO)
            cls.forms = [
                create_form_and_sync_to_es(cls.now),
                create_form_and_sync_to_es(cls.now - cls._60_days)
            ]

        cls.elasticsearch.indices.refresh(XFORM_INDEX_INFO.index)
예제 #13
0
 def tearDownClass(cls):
     cls.middlesex_web_user.delete()
     cls.massachusetts_web_user.delete()
     cls.locationless_web_user.delete()
     cls.project_admin.delete()
     cls.domain_obj.delete()
     delete_all_locations()
     delete_all_xforms()
예제 #14
0
    def setUp(self):
        delete_all_cases()
        delete_all_xforms()
        delete_all_sync_logs()

        # this creates the initial blank sync token in the database
        generate_restore_payload(self.project, self.user)
        self.sync_log = get_exactly_one_wrapped_sync_log()
예제 #15
0
 def tearDownClass(cls):
     cls.middlesex_web_user.delete()
     cls.massachusetts_web_user.delete()
     cls.locationless_web_user.delete()
     cls.project_admin.delete()
     cls.domain_obj.delete()
     delete_all_locations()
     delete_all_xforms()
예제 #16
0
 def tearDown(self):
     delete_all_xforms()
     delete_all_cases()
     delete_all_sync_logs()
     restore_config = RestoreConfig(project=self.project,
                                    restore_user=self.restore_user)
     restore_config.cache.delete(restore_config._initial_cache_key)
     super(BaseOtaRestoreTest, self).tearDown()
예제 #17
0
 def tearDown(self):
     delete_all_cases()
     delete_all_xforms()
     AsyncIndicator.objects.all().delete()
     InvalidUCRData.objects.all().delete()
     self.config = DataSourceConfiguration.get(self.config.data_source_id)
     self.config.validations = []
     self.config.save()
예제 #18
0
 def tearDown(self):
     self.adapter.clear_table()
     delete_all_cases()
     delete_all_xforms()
     InvalidUCRData.objects.all().delete()
     self.config = DataSourceConfiguration.get(self.config.data_source_id)
     self.config.validations = []
     self.config.save()
    def setUp(self):
        delete_all_cases()
        delete_all_xforms()
        delete_all_sync_logs()

        # this creates the initial blank sync token in the database
        self.device = MockDevice(self.project, self.user)
        self.device.sync(version=V1)
예제 #20
0
 def setUp(self):
     self.domain = Domain.get_or_create_with_name(TEST_DOMAIN_NAME, is_active=True)
     self.user = WebUser.create(TEST_DOMAIN_NAME, TEST_USER, TEST_PASSWORD)
     self.user.set_role(self.domain.name, "admin")
     self.user.save()
     self.interface = FormProcessorInterface(TEST_DOMAIN_NAME)
     delete_all_cases()
     delete_all_xforms()
     time.sleep(1)
예제 #21
0
    def setUp(self):
        super(StateHashTest, self).setUp()
        delete_all_cases()
        delete_all_xforms()
        delete_all_sync_logs()

        # this creates the initial blank sync token in the database
        self.device = MockDevice(self.project, self.user)
        self.device.sync(version=V1)
예제 #22
0
 def tearDown(self):
     SQLLocation.objects.all().delete()
     self.backend_mapping.delete()
     self.backend.delete()
     delete_all_xforms()
     delete_all_cases()
     delete_all_sync_logs()
     delete_all_users()
     self.domain.delete()  # domain delete cascades to everything else
예제 #23
0
 def setUp(self):
     self.domain = Domain.get_or_create_with_name(TEST_DOMAIN_NAME,
                                                  is_active=True)
     self.user = WebUser.create(TEST_DOMAIN_NAME, TEST_USER, TEST_PASSWORD)
     self.user.set_role(self.domain.name, 'admin')
     self.user.save()
     self.interface = FormProcessorInterface(TEST_DOMAIN_NAME)
     delete_all_cases()
     delete_all_xforms()
     time.sleep(1)
예제 #24
0
 def tearDown(self):
     SQLLocation.objects.all().delete()
     self.backend_mapping.delete()
     self.backend.delete()
     delete_all_xforms()
     delete_all_cases()
     delete_all_sync_logs()
     delete_all_users()
     self.domain.delete()  # domain delete cascades to everything else
     super(CommTrackTest, self).tearDown()
예제 #25
0
    def setUp(self):
        delete_all_cases()
        delete_all_xforms()
        delete_all_sync_logs()

        self.user = User(user_id=USER_ID, username="******", 
                         password="******", date_joined=datetime(2011, 6, 9)) 
        # this creates the initial blank sync token in the database
        restore_config = RestoreConfig(self.user)
        self.sync_log = synclog_from_restore_payload(restore_config.get_payload())
예제 #26
0
    def setUp(self):
        delete_all_cases()
        delete_all_xforms()
        delete_all_sync_logs()
        self.project = Domain(name='state-hash-tests-project')
        self.user = User(user_id="state_hash", username="******",
                         password="******", date_joined=datetime(2011, 6, 9))

        # this creates the initial blank sync token in the database
        generate_restore_payload(self.project, self.user)
        self.sync_log = get_exactly_one_wrapped_sync_log()
예제 #27
0
    def setUp(self):
        super(UTHTests, self).setUp()
        delete_all_xforms()
        delete_all_cases()

        self.domain = create_domain(UTH_DOMAIN)

        username = format_username("vscan_user", UTH_DOMAIN)

        self.vscan_user = CommCareUser.get_by_username(username) or CommCareUser.create(UTH_DOMAIN, username, "secret")

        self.case_id = self.create_scan_case(self.vscan_user._id, "VH014466XK", "123123", "2014-03-28T10:48:49Z")
예제 #28
0
    def setUp(self):
        delete_all_xforms()
        for item in FormData.objects.all():
            item.delete()

        file_path = os.path.join(os.path.dirname(__file__), "data", "meta.xml")
        with open(file_path, "rb") as f:
            xml_data = f.read()

        submit_form_locally(xml_data, 'sofabed', app_id='12345', received_on=datetime.utcnow())

        self.instance = XFormInstance.get('THIS_IS_THE_INSTANCEID')
예제 #29
0
    def setUp(self):
        delete_all_cases()
        delete_all_xforms()
        delete_all_sync_logs()

        self.user = User(user_id="state_hash", username="******",
                         password="******", date_joined=datetime(2011, 6, 9)) 
        
        # this creates the initial blank sync token in the database
        generate_restore_payload(self.user)
        [sync_log] = SyncLog.view("phone/sync_logs_by_user", include_docs=True, reduce=False).all()
        self.sync_log = sync_log
예제 #30
0
    def setUp(self):
        delete_all_cases()
        delete_all_xforms()
        delete_all_sync_logs()
        delete_all_users()
        self.project = Domain(name='state-hash-tests-project')
        self.project.save()
        self.user = create_restore_user(domain=self.project.name)

        # this creates the initial blank sync token in the database
        generate_restore_payload(self.project, self.user)
        self.sync_log = get_exactly_one_wrapped_sync_log()
예제 #31
0
    def setUp(self):
        delete_all_cases()
        delete_all_xforms()
        delete_all_sync_logs()
        delete_all_users()
        self.project = Domain(name='state-hash-tests-project')
        self.project.save()
        self.user = create_restore_user(domain=self.project.name)

        # this creates the initial blank sync token in the database
        generate_restore_payload(self.project, self.user)
        self.sync_log = get_exactly_one_wrapped_sync_log()
예제 #32
0
    def setUp(self):
        delete_all_cases()
        delete_all_xforms()
        delete_all_sync_logs()

        self.user = User(user_id=USER_ID,
                         username="******",
                         password="******",
                         date_joined=datetime(2011, 6, 9))
        # this creates the initial blank sync token in the database
        restore_config = RestoreConfig(self.user)
        self.sync_log = synclog_from_restore_payload(
            restore_config.get_payload())
예제 #33
0
    def tearDownClass(cls):
        with cls.engine.begin() as connection:
            cls.recap_table.drop(connection, checkfirst=True)
            cls.intra_table.drop(connection, checkfirst=True)
            cls.taux_rupt_table.drop(connection, checkfirst=True)
            cls.livraison_table.drop(connection, checkfirst=True)
            cls.taux_sat_table.drop(connection, checkfirst=True)
            cls.couverture_table.drop(connection, checkfirst=True)

        cls.engine.dispose()
        cls.domain.delete()
        delete_all_xforms()
        super(IntraHealthTestCase, cls).tearDownClass()
예제 #34
0
    def tearDownClass(cls):
        with cls.engine.begin() as connection:
            cls.recap_table.drop(connection, checkfirst=True)
            cls.intra_table.drop(connection, checkfirst=True)
            cls.taux_rupt_table.drop(connection, checkfirst=True)
            cls.livraison_table.drop(connection, checkfirst=True)
            cls.taux_sat_table.drop(connection, checkfirst=True)
            cls.couverture_table.drop(connection, checkfirst=True)

        cls.engine.dispose()
        cls.domain.delete()
        delete_all_xforms()
        super(IntraHealthTestCase, cls).tearDownClass()
예제 #35
0
    def setUp(self):
        super(UTHTests, self).setUp()
        delete_all_xforms()
        delete_all_cases()

        self.domain = create_domain(UTH_DOMAIN)

        username = format_username('vscan_user', UTH_DOMAIN)

        self.vscan_user = CommCareUser.get_by_username(
            username) or CommCareUser.create(UTH_DOMAIN, username, 'secret')

        self.case_id = self.create_scan_case(self.vscan_user._id, 'VH014466XK',
                                             '123123', '2014-03-28T10:48:49Z')
예제 #36
0
    def setUpClass(cls):
        from casexml.apps.case.tests.util import delete_all_xforms
        delete_all_xforms()
        cls.domain = 'evelyn'
        cls.now = datetime.datetime.utcnow()
        cls.xforms = [
            XFormInstance(_id='xform_1',
                          received_on=cls.now - datetime.timedelta(days=10)),
            XFormInstance(_id='xform_2', received_on=cls.now)
        ]
        cls.xform_errors = [XFormError(_id='xform_error_1')]

        for form in cls.xforms + cls.xform_errors:
            form.domain = cls.domain
            form.save()
예제 #37
0
    def setUpClass(cls):
        super(ExportsFormsAnalyticsTest, cls).setUpClass()
        from casexml.apps.case.tests.util import delete_all_xforms
        from corehq.apps.app_manager.models import Application, Module, Form
        delete_all_xforms()

        with trap_extra_setup(ConnectionError,
                              msg="cannot connect to elasicsearch"):
            cls.es = get_es_new()
            initialize_index_and_mapping(cls.es, XFORM_INDEX_INFO)

        cls.domain = 'exports_forms_analytics_domain'
        cls.app_id_1 = 'a' + uuid.uuid4().hex
        cls.app_id_2 = 'b' + uuid.uuid4().hex
        cls.xmlns_1 = 'my://crazy.xmlns/'
        cls.xmlns_2 = 'my://crazy.xmlns/app'
        cls.apps = [
            Application(_id=cls.app_id_2,
                        domain=cls.domain,
                        modules=[Module(forms=[Form(xmlns=cls.xmlns_2)])])
        ]
        for app in cls.apps:
            app.save()
        cls.forms = [
            create_form_for_test(domain=cls.domain,
                                 app_id=cls.app_id_1,
                                 xmlns=cls.xmlns_1,
                                 save=False),
            create_form_for_test(domain=cls.domain,
                                 app_id=cls.app_id_1,
                                 xmlns=cls.xmlns_1,
                                 save=False),
            create_form_for_test(domain=cls.domain,
                                 app_id=cls.app_id_2,
                                 xmlns=cls.xmlns_2,
                                 save=False),
        ]
        cls.error_forms = [
            create_form_for_test(domain=cls.domain,
                                 state=XFormInstance.ERROR,
                                 save=False)
        ]
        cls.all_forms = cls.forms + cls.error_forms
        for form in cls.all_forms:
            elastic_form = transform_xform_for_elasticsearch(form.to_json())
            send_to_elasticsearch('forms', elastic_form)

        cls.es.indices.refresh(XFORM_INDEX_INFO.alias)
예제 #38
0
    def setUp(self):
        super(CommTrackTest, self).setUp()
        # might as well clean house before doing anything
        delete_all_xforms()
        delete_all_cases()
        delete_all_sync_logs()

        StockReport.objects.all().delete()
        StockTransaction.objects.all().delete()

        self.backend, self.backend_mapping = setup_default_sms_test_backend()

        self.domain = bootstrap_domain(TEST_DOMAIN)
        bootstrap_location_types(self.domain.name)
        bootstrap_products(self.domain.name)
        self.ct_settings = CommtrackConfig.for_domain(self.domain.name)
        self.ct_settings.consumption_config = ConsumptionConfig(
            min_transactions=0,
            min_window=0,
            optimal_window=60,
            min_periods=0,
        )
        # todo: remove?
        if self.requisitions_enabled:
            self.ct_settings.requisition_config = get_default_requisition_config(
            )

        self.ct_settings.save()

        self.domain = Domain.get(self.domain._id)

        self.loc = make_loc('loc1')
        self.sp = self.loc.linked_supply_point()
        self.users = [
            bootstrap_user(self, **user_def)
            for user_def in self.user_definitions
        ]

        # everyone should be in a group.
        self.group = Group(domain=TEST_DOMAIN,
                           name='commtrack-folks',
                           users=[u._id for u in self.users],
                           case_sharing=True)
        self.group._id = self.sp.owner_id
        self.group.save()
        self.products = sorted(Product.by_domain(self.domain.name),
                               key=lambda p: p._id)
        self.assertEqual(3, len(self.products))
예제 #39
0
    def setUp(self):
        super(CommTrackTest, self).setUp()
        # might as well clean house before doing anything
        delete_all_xforms()
        delete_all_cases()
        delete_all_sync_logs()

        StockReport.objects.all().delete()
        StockTransaction.objects.all().delete()

        self.backend, self.backend_mapping = setup_default_sms_test_backend()

        self.domain = bootstrap_domain(TEST_DOMAIN)
        bootstrap_location_types(self.domain.name)
        bootstrap_products(self.domain.name)
        self.ct_settings = CommtrackConfig.for_domain(self.domain.name)
        self.ct_settings.consumption_config = ConsumptionConfig(
            min_transactions=0,
            min_window=0,
            optimal_window=60,
            min_periods=0,
        )
        # todo: remove?
        if self.requisitions_enabled:
            self.ct_settings.requisition_config = get_default_requisition_config()

        self.ct_settings.save()

        self.domain = Domain.get(self.domain._id)

        self.loc = make_loc('loc1')
        self.sp = self.loc.linked_supply_point()
        self.users = [bootstrap_user(self, **user_def) for user_def in self.user_definitions]

        # everyone should be in a group.
        self.group = Group(domain=TEST_DOMAIN, name='commtrack-folks',
                           users=[u._id for u in self.users],
                           case_sharing=True)
        self.group._id = self.sp.owner_id
        self.group.save()
        self.products = sorted(Product.by_domain(self.domain.name), key=lambda p: p._id)
        self.assertEqual(3, len(self.products))
예제 #40
0
    def setUp(self):
        delete_all_xforms()
        delete_all_cases()

        self.domain = create_domain(UTH_DOMAIN)

        username = format_username('vscan_user', UTH_DOMAIN)

        self.vscan_user = CommCareUser.get_by_username(username) or CommCareUser.create(
            UTH_DOMAIN,
            username,
            'secret'
        )

        self.case_id = self.create_scan_case(
            self.vscan_user._id,
            'VH014466XK',
            '123123',
            '2014-03-28T10:48:49Z'
        )
예제 #41
0
    def setUpClass(cls):
        from casexml.apps.case.tests.util import delete_all_xforms
        from corehq.apps.app_manager.models import Application, Module, Form
        delete_all_xforms()

        with trap_extra_setup(ConnectionError,
                              msg="cannot connect to elasicsearch"):
            cls.es = get_es_new()
            initialize_index_and_mapping(cls.es, XFORM_INDEX_INFO)

        cls.domain = 'exports_forms_analytics_domain'
        cls.app_id_1 = 'a' + uuid.uuid4().hex
        cls.app_id_2 = 'b' + uuid.uuid4().hex
        cls.xmlns_1 = 'my://crazy.xmlns/'
        cls.xmlns_2 = 'my://crazy.xmlns/app'
        cls.apps = [
            Application(_id=cls.app_id_2,
                        domain=cls.domain,
                        modules=[Module(forms=[Form(xmlns=cls.xmlns_2)])])
        ]
        for app in cls.apps:
            app.save()
        cls.forms = [
            XFormInstance(domain=cls.domain,
                          app_id=cls.app_id_1,
                          xmlns=cls.xmlns_1),
            XFormInstance(domain=cls.domain,
                          app_id=cls.app_id_1,
                          xmlns=cls.xmlns_1),
            XFormInstance(domain=cls.domain,
                          app_id=cls.app_id_2,
                          xmlns=cls.xmlns_2),
        ]
        cls.error_forms = [XFormError(domain=cls.domain)]
        cls.all_forms = cls.forms + cls.error_forms
        for form in cls.all_forms:
            form.save()
            send_to_elasticsearch('forms', form.to_json())

        cls.es.indices.refresh(XFORM_INDEX_INFO.index)
        update_analytics_indexes()
예제 #42
0
    def setUpClass(cls):
        super(ExportsFormsAnalyticsTest, cls).setUpClass()
        from casexml.apps.case.tests.util import delete_all_xforms
        from corehq.apps.app_manager.models import Application, Module, Form
        delete_all_xforms()

        with trap_extra_setup(ConnectionError, msg="cannot connect to elasicsearch"):
            cls.es = get_es_new()
            initialize_index_and_mapping(cls.es, XFORM_INDEX_INFO)

        cls.domain = 'exports_forms_analytics_domain'
        cls.app_id_1 = 'a' + uuid.uuid4().hex
        cls.app_id_2 = 'b' + uuid.uuid4().hex
        cls.xmlns_1 = 'my://crazy.xmlns/'
        cls.xmlns_2 = 'my://crazy.xmlns/app'
        cls.apps = [
            Application(_id=cls.app_id_2, domain=cls.domain,
                        modules=[Module(forms=[Form(xmlns=cls.xmlns_2)])])
        ]
        for app in cls.apps:
            app.save()
        cls.forms = [
            XFormInstance(domain=cls.domain,
                          app_id=cls.app_id_1, xmlns=cls.xmlns_1),
            XFormInstance(domain=cls.domain,
                          app_id=cls.app_id_1, xmlns=cls.xmlns_1),
            XFormInstance(domain=cls.domain,
                          app_id=cls.app_id_2, xmlns=cls.xmlns_2),
        ]
        cls.error_forms = [XFormError(domain=cls.domain)]
        cls.all_forms = cls.forms + cls.error_forms
        for form in cls.all_forms:
            form.save()
            send_to_elasticsearch('forms', form.to_json())

        cls.es.indices.refresh(XFORM_INDEX_INFO.index)
        update_analytics_indexes()
예제 #43
0
    def setUpClass(cls):
        from casexml.apps.case.tests.util import delete_all_xforms
        from corehq.apps.app_manager.models import Application, Module, Form
        delete_all_xforms()

        cls.form_pillow = XFormPillow(online=False)
        with trap_extra_setup(ConnectionError, msg="cannot connect to elasicsearch"):
            completely_initialize_pillow_index(cls.form_pillow)

        cls.domain = 'exports_forms_analytics_domain'
        cls.app_id_1 = 'a' + uuid.uuid4().hex
        cls.app_id_2 = 'b' + uuid.uuid4().hex
        cls.xmlns_1 = 'my://crazy.xmlns/'
        cls.xmlns_2 = 'my://crazy.xmlns/app'
        cls.apps = [
            Application(_id=cls.app_id_2, domain=cls.domain,
                        modules=[Module(forms=[Form(xmlns=cls.xmlns_2)])])
        ]
        for app in cls.apps:
            app.save()
        cls.forms = [
            XFormInstance(domain=cls.domain,
                          app_id=cls.app_id_1, xmlns=cls.xmlns_1),
            XFormInstance(domain=cls.domain,
                          app_id=cls.app_id_1, xmlns=cls.xmlns_1),
            XFormInstance(domain=cls.domain,
                          app_id=cls.app_id_2, xmlns=cls.xmlns_2),
        ]
        cls.error_forms = [XFormError(domain=cls.domain)]
        cls.all_forms = cls.forms + cls.error_forms
        for form in cls.all_forms:
            form.save()
            cls.form_pillow.send_robust(form.to_json())

        cls.form_pillow.get_es_new().indices.refresh(cls.form_pillow.es_index)
        update_analytics_indexes()
예제 #44
0
    def setUpClass(cls):
        super(TestDBAccessors, cls).setUpClass()
        from casexml.apps.case.tests.util import delete_all_xforms
        delete_all_xforms()
        cls.domain = 'evelyn'
        cls.now = datetime.datetime(2017, 10, 31)
        cls.user_id1 = 'xzy'
        cls.user_id2 = 'abc'

        metadata1 = TestFormMetadata(
            domain=cls.domain,
            user_id=cls.user_id1,
            received_on=cls.now - datetime.timedelta(days=10),
        )
        metadata2 = TestFormMetadata(
            domain=cls.domain,
            user_id=cls.user_id2,
            received_on=cls.now,
        )

        cls.xform1 = get_simple_wrapped_form('123', metadata=metadata1)
        cls.xform2 = get_simple_wrapped_form('456', metadata=metadata2)

        xform_error = get_simple_wrapped_form('789', metadata=metadata2)
        xform_error = XFormError.wrap(xform_error.to_json())
        xform_error.save()

        cls.xform_deleted = get_simple_wrapped_form('101', metadata=metadata2)
        cls.xform_deleted.doc_type += '-Deleted'
        cls.xform_deleted.save()

        cls.xforms = [
            cls.xform1,
            cls.xform2,
        ]
        cls.xform_errors = [xform_error]
예제 #45
0
 def tearDown(self):
     delete_all_cases()
     delete_all_xforms()
     self.primary_user.delete()
     self.original_owner.delete()
예제 #46
0
 def tearDown(self):
     delete_all_xforms()
     delete_all_cases()
     self.domain_object.delete()
     DomainMigrationProgress.objects.all().delete()
     super(TimeZoneMigrationTest, self).tearDown()
 def tearDownClass(cls):
     delete_all_xforms()
     delete_all_cases()
     for index_info in cls.es_indices:
         ensure_index_deleted(index_info.index)
     super(TestFormsExpressionSpecWithFilter, cls).tearDownClass()
예제 #48
0
 def tearDown(self):
     for adapter in self.adapters:
         adapter.drop_table()
         adapter.config.delete()
     delete_all_cases()
     delete_all_xforms()
예제 #49
0
 def tearDownClass(cls):
     delete_all_cases()
     delete_all_xforms()
     super(FormAndCaseIdsTest, cls).tearDownClass()
예제 #50
0
 def tearDown(self):
     delete_all_xforms()
예제 #51
0
 def tearDownClass(cls):
     cls.config.delete()
     cls.adapter.drop_table()
     delete_all_cases()
     delete_all_xforms()
     super(AsyncIndicatorTest, cls).tearDownClass()
예제 #52
0
 def setUp(self):
     super(CaseBugTest, self).setUp()
     delete_all_cases()
     delete_all_xforms()
예제 #53
0
 def tearDownClass(cls):
     cls.domain_obj.delete()
     delete_all_users()
     delete_all_locations()
     delete_all_xforms()
예제 #54
0
 def tearDown(self):
     self.config.delete()
     self.adapter.drop_table()
     delete_all_cases()
     delete_all_xforms()
예제 #55
0
 def setUp(self):
     delete_all_cases()
     delete_all_xforms()
예제 #56
0
 def tearDown(self):
     for user in CommCareUser.all():
         user.delete()
     delete_all_cases()
     delete_all_xforms()
예제 #57
0
 def setUp(self):
     delete_all_xforms()
예제 #58
0
 def tearDownClass(cls):
     cls.config.delete()
     cls.adapter.drop_table()
     delete_all_cases()
     delete_all_xforms()
     super(AsyncIndicatorTest, cls).tearDownClass()