Ejemplo n.º 1
0
 def test_couch_wrap_lock_dependency_couch(self):
     # valid combinations
     CaseDbCacheCouch(domain='some-domain', lock=False, wrap=True)
     CaseDbCacheCouch(domain='some-domain', lock=False, wrap=False)
     CaseDbCacheCouch(domain='some-domain', lock=True, wrap=True)
     with self.assertRaises(ValueError):
         # invalid
         CaseDbCacheCouch(domain='some-domain', lock=True, wrap=False)
Ejemplo n.º 2
0
    def testDocTypeCheck(self):
        id = uuid.uuid4().hex
        CommCareCase.get_db().save_doc({
            "_id": id,
            "doc_type": "AintNoCasesHere"
        })
        doc_back = CommCareCase.get_db().get(id)
        self.assertEqual("AintNoCasesHere", doc_back['doc_type'])

        cache = CaseDbCacheCouch()
        try:
            cache.get(id)
            self.fail('doc type security check failed to raise exception')
        except IllegalCaseId:
            pass
Ejemplo n.º 3
0
    def testDocTypeCheck(self):
        id = uuid.uuid4().hex
        CommCareCase.get_db().save_doc({
            "_id": id,
            "doc_type": "AintNoCasesHere"
        })
        doc_back = CommCareCase.get_db().get(id)
        self.assertEqual("AintNoCasesHere", doc_back['doc_type'])

        cache = CaseDbCacheCouch()
        try:
            cache.get(id)
            self.fail('doc type security check failed to raise exception')
        except IllegalCaseId:
            pass
Ejemplo n.º 4
0
def _process_cases(xform, config=None):
    """
    Creates or updates case objects which live outside of the form.

    If reconcile is true it will perform an additional step of
    reconciling the case update history after the case is processed.
    """
    warnings.warn(
        'This function is deprecated. You should be using SubmissionPost.',
        DeprecationWarning,
    )

    assert getattr(settings, 'UNIT_TESTING', False)
    domain = get_and_check_xform_domain(xform)

    with CaseDbCacheCouch(domain=domain, lock=True,
                          deleted_ok=True) as case_db:
        case_result = process_cases_with_casedb([xform],
                                                case_db,
                                                config=config)

    cases = case_result.cases
    docs = [xform] + cases
    now = datetime.datetime.utcnow()
    for case in cases:
        case.server_modified_on = now