def class_setup_reindex(cls):
        cls.domain = uuid.uuid4().hex
        cls.other_domain = uuid.uuid4().hex
        # since this test depends on the global form list just wipe everything
        FormProcessorTestUtils.delete_all_sql_forms()
        FormProcessorTestUtils.delete_all_v2_ledgers()
        FormProcessorTestUtils.delete_all_sql_cases()

        cls.first_batch_domain = cls._get_doc_ids(
            cls._create_docs(cls.domain, 4))
        cls.first_batch_global = cls.first_batch_domain + cls._get_doc_ids(
            cls._create_docs(cls.other_domain, 4))
        cls.middle = datetime.utcnow()
        time.sleep(.02)
        cls.second_batch_domain = cls._get_doc_ids(
            cls._create_docs(cls.domain, 4))
        cls.second_batch_global = cls.second_batch_domain + cls._get_doc_ids(
            cls._create_docs(cls.other_domain, 4))
        time.sleep(.02)
        cls.end = datetime.utcnow()

        cls.all_doc_ids = cls.first_batch_global + cls.second_batch_global
        cls.all_doc_ids_domain = cls.first_batch_domain + cls.second_batch_domain

        cls._analyse()
    def test_get_forms_received_since(self):
        # since this test depends on the global form list just wipe everything
        FormProcessorTestUtils.delete_all_sql_forms()

        form1 = create_form_for_test(DOMAIN)
        form2 = create_form_for_test(DOMAIN)
        middle = datetime.utcnow()
        time.sleep(.01)
        form3 = create_form_for_test(DOMAIN)
        form4 = create_form_for_test(DOMAIN)
        time.sleep(.01)
        end = datetime.utcnow()

        forms_back = list(FormAccessorSQL.get_all_forms_received_since())
        self.assertEqual(4, len(forms_back))
        self.assertEqual(set(form.form_id for form in forms_back),
                         set([form1.form_id, form2.form_id, form3.form_id, form4.form_id]))

        forms_back = list(FormAccessorSQL.get_all_forms_received_since(middle))
        self.assertEqual(2, len(forms_back))
        self.assertEqual(set(form.form_id for form in forms_back),
                         set([form3.form_id, form4.form_id]))

        self.assertEqual(0, len(list(FormAccessorSQL.get_all_forms_received_since(end))))
        self.assertEqual(1, len(list(FormAccessorSQL.get_forms_received_since(limit=1))))
Example #3
0
    def tearDownClass(cls):
        for user in cls.user_records:
            user.delete()

        for domain in cls.domain_records:
            domain.delete()

        FormProcessorTestUtils.delete_all_sql_forms(cls.domain)

        reset_warehouse_db()
        super(AppStatusIntegrationTest, cls).tearDownClass()
 def setUpClass(cls):
     if settings.USE_PARTITIONED_DATABASE:
         # https://github.com/nose-devs/nose/issues/946
         raise SkipTest('Only applicable if no sharding is setup')
     super(BaseReindexAccessorTest, cls).setUpClass()
     cls.domain = uuid.uuid4().hex
     cls.other_domain = uuid.uuid4().hex
     # since this test depends on the global form list just wipe everything
     FormProcessorTestUtils.delete_all_sql_forms()
     FormProcessorTestUtils.delete_all_v2_ledgers()
     FormProcessorTestUtils.delete_all_sql_cases()
Example #5
0
 def tearDownClass(cls):
     ensure_index_deleted(USER_INDEX_INFO.alias)
     ensure_index_deleted(XFORM_INDEX_INFO.alias)
     for user in cls.users:
         user.delete(cls.domain.name, None)
     FormProcessorTestUtils.delete_all_sql_forms(cls.domain.name)
     FormProcessorTestUtils.delete_all_sql_cases(cls.domain.name)
     Invitation.objects.all().delete()
     DomainUserHistory.objects.all().delete()
     cls.domain.delete()
     super().tearDownClass()
 def setUpClass(cls):
     if settings.USE_PARTITIONED_DATABASE:
         # https://github.com/nose-devs/nose/issues/946
         raise SkipTest('Only applicable if no sharding is setup')
     super(BaseReindexAccessorTest, cls).setUpClass()
     cls.domain = uuid.uuid4().hex
     cls.other_domain = uuid.uuid4().hex
     # since this test depends on the global form list just wipe everything
     FormProcessorTestUtils.delete_all_sql_forms()
     FormProcessorTestUtils.delete_all_v2_ledgers()
     FormProcessorTestUtils.delete_all_sql_cases()
Example #7
0
    def tearDownClass(cls):
        for user in cls.user_records:
            user.delete()

        for domain in cls.domain_records:
            domain.delete()

        FormProcessorTestUtils.delete_all_sql_forms(cls.domain)

        DomainStagingTable.clear_records()
        DomainDim.clear_records()
        UserStagingTable.clear_records()
        UserDim.clear_records()
        FormStagingTable.clear_records()
        FormFact.clear_records()
Example #8
0
    def class_setup_reindex(cls):
        cls.domain = uuid.uuid4().hex
        # since this test depends on the global form list just wipe everything
        FormProcessorTestUtils.delete_all_sql_forms()
        FormProcessorTestUtils.delete_all_v2_ledgers()
        FormProcessorTestUtils.delete_all_sql_cases()

        cls.first_batch = cls._get_doc_ids(cls._create_docs(4))
        cls.middle = datetime.utcnow()
        time.sleep(.02)
        cls.second_batch = cls._get_doc_ids(cls._create_docs(4))
        time.sleep(.02)
        cls.end = datetime.utcnow()

        cls._analyse()
Example #9
0
    def tearDownClass(cls):
        for user in cls.user_records:
            user.delete()

        for domain in cls.domain_records:
            domain.delete()

        FormProcessorTestUtils.delete_all_sql_forms(cls.domain)

        FormStagingTable.clear_records()
        FormFact.clear_records()
        DomainStagingTable.clear_records()
        DomainDim.clear_records()
        UserStagingTable.clear_records()
        UserDim.clear_records()
        super(FormFactIntegrationTest, cls).tearDownClass()
 def tearDownClass(cls):
     FormProcessorTestUtils.delete_all_sql_forms()
     FormProcessorTestUtils.delete_all_v2_ledgers()
     FormProcessorTestUtils.delete_all_sql_cases()
     super(BaseReindexAccessorTest, cls).tearDownClass()
 def tearDownClass(cls):
     FormProcessorTestUtils.delete_all_sql_forms()
     FormProcessorTestUtils.delete_all_sql_cases()
     super(SqlUpdateStrategyTest, cls).tearDownClass()
 def setUpClass(cls):
     super(SqlUpdateStrategyTest, cls).setUpClass()
     FormProcessorTestUtils.delete_all_sql_forms()
     FormProcessorTestUtils.delete_all_sql_cases()
Example #13
0
 def tearDown(self):
     FormProcessorTestUtils.delete_all_sql_forms(DOMAIN)
     FormProcessorTestUtils.delete_all_sql_cases(DOMAIN)
     super(ShardingTests, self).tearDown()
Example #14
0
 def setUpClass(cls):
     super(SqlUpdateStrategyTest, cls).setUpClass()
     FormProcessorTestUtils.delete_all_sql_forms()
     FormProcessorTestUtils.delete_all_sql_cases()
Example #15
0
 def tearDownClass(cls):
     cls.user.delete()
     cls.registry.delete()
     FormProcessorTestUtils.delete_all_sql_forms(cls.domain)
     FormProcessorTestUtils.delete_all_sql_cases(cls.domain)
     super().tearDownClass()
 def tearDownClass(cls):
     for domain in cls.domains:
         FormProcessorTestUtils.delete_all_sql_forms(domain)
     super(TestSqlDomainFormChangeProvider, cls).tearDownClass()
Example #17
0
 def tearDown(self):
     if settings.USE_PARTITIONED_DATABASE:
         FormProcessorTestUtils.delete_all_sql_forms(DOMAIN)
         FormProcessorTestUtils.delete_all_sql_cases(DOMAIN)
     super(BaseCaseManagerTest, self).tearDown()
Example #18
0
 def tearDownClass(cls):
     if settings.USE_PARTITIONED_DATABASE:
         FormProcessorTestUtils.delete_all_sql_forms(DOMAIN)
         FormProcessorTestUtils.delete_all_sql_forms('d2')
     super().tearDownClass()
 def tearDown(self):
     FormProcessorTestUtils.delete_all_sql_forms(DOMAIN)
     FormProcessorTestUtils.delete_all_sql_cases(DOMAIN)
     super(CaseAccessorTestsSQL, self).tearDown()
 def tearDownClass(cls):
     for domain in cls.domains:
         FormProcessorTestUtils.delete_all_sql_forms(domain)
     super(TestSqlDomainFormChangeProvider, cls).tearDownClass()
 def tearDownClass(cls):
     FormProcessorTestUtils.delete_all_sql_forms()
     FormProcessorTestUtils.delete_all_v2_ledgers()
     FormProcessorTestUtils.delete_all_sql_cases()
     super(BaseReindexAccessorTest, cls).tearDownClass()
 def tearDown(self):
     FormProcessorTestUtils.delete_all_sql_forms(DOMAIN)
     FormProcessorTestUtils.delete_all_sql_cases(DOMAIN)
     super(CaseAccessorTestsSQL, self).tearDown()
Example #23
0
 def class_teardown_reindex(cls):
     FormProcessorTestUtils.delete_all_sql_forms()
     FormProcessorTestUtils.delete_all_v2_ledgers()
     FormProcessorTestUtils.delete_all_sql_cases()
Example #24
0
 def tearDownClass(cls):
     FormProcessorTestUtils.delete_all_sql_forms()
     FormProcessorTestUtils.delete_all_sql_cases()
     super(SqlUpdateStrategyTest, cls).tearDownClass()
 def tearDown(self):
     FormProcessorTestUtils.delete_all_sql_forms(DOMAIN)
     FormProcessorTestUtils.delete_all_sql_cases(DOMAIN)
Example #26
0
 def tearDown(self):
     FormProcessorTestUtils.delete_all_sql_forms(DOMAIN)
     FormProcessorTestUtils.delete_all_sql_cases(DOMAIN)
     super(ShardingTests, self).tearDown()
 def class_teardown_reindex(cls):
     FormProcessorTestUtils.delete_all_sql_forms()
     FormProcessorTestUtils.delete_all_v2_ledgers()
     FormProcessorTestUtils.delete_all_sql_cases()