예제 #1
0
def verify_doc_in_DB(doc_name):
    # get or insert into Document table
    doc = BLL_Documents.single_document_by_name(doc_name)
    if doc:
        print('found it')
    else:
        print('not there')
        doc_data = {"doc_name": doc_name}
        r = BLL_Documents.create_document(doc_data=doc_data)
        print(r)
예제 #2
0
def test_create_doc_group_relationships():
    # get a random existing document
    docs = BLL_Documents.get_documents()
    y = random.randint(1, len(docs))
    aDoc = docs[y]
    aDoc_dict = aDoc.to_dict()
    doc_id = aDoc_dict['doc_id']

    y = random.randint(1, len(docs))
    aDoc = docs[y]
    aDoc_dict = aDoc.to_dict()
    append_doc_id = aDoc_dict['doc_id']

    # create a section
    # get random existing section
    sections = BLL_Sections.get_sections()
    u = random.randint(1, len(sections))
    aSection = sections[u]
    aSection_dict = aSection.to_dict()
    sec_id = aSection_dict['sec_id']

    # # create a group
    # group_data = {"doc_id": doc_id,
    #               "sec_id": sec_id}
    # r = BLL_Groups.create_group(group_data)
    # group_id = r["msg"]
    # print("created group" + group_id)

    j_body = {"doc_id": doc_id, "append_doc_id": append_doc_id}
    r = BLL_DocGroupSections.attach_sections(j_body)
예제 #3
0
def test_create_multiple_docs():
    range_start = 1
    range_stop = 3

    for i in range(range_start, range_stop):
        doc_data = {"doc_name": "doc" + str(i)}
        r1 = BLL_Documents.create_document(doc_data=doc_data)
        for t in range(range_start, range_stop):
            doc_data = {"doc_name": "doc" + str((i * 10) + t)}
            r2 = BLL_Documents.create_document(doc_data=doc_data)
            #
            # doc_rel_data1 = {"doc_id": r2['msg'],
            #             "parent_id": r1['msg'],
            #             "relationship": "copy"}
            #
            # s = BLL_Doc_Parent.create_doc_parent(doc_rel_data1)

            j_body = {"doc_id": r2['msg'], "append_doc_id": r1['msg']}
            r = BLL_DocGroupSections.attach_sections(j_body)

            for g in range(range_start, range_stop):
                doc_data = {"doc_name": "doc" + str((i * 100) + g)}
                r3 = BLL_Documents.create_document(doc_data=doc_data)

                j_body = {"doc_id": r3['msg'], "append_doc_id": r2['msg']}
                r = BLL_DocGroupSections.attach_sections(j_body)

                for h in range(range_start, range_stop):
                    doc_data = {"doc_name": "doc" + str((i * 1000) + h)}
                    r4 = BLL_Documents.create_document(doc_data=doc_data)

                    j_body = {"doc_id": r4['msg'], "append_doc_id": r3['msg']}
                    r = BLL_DocGroupSections.attach_sections(j_body)

                    for q in range(range_start, range_stop):
                        doc_data = {"doc_name": "doc" + str((i * 10000) + q)}
                        r5 = BLL_Documents.create_document(doc_data=doc_data)

                        j_body = {
                            "doc_id": r5['msg'],
                            "append_doc_id": r4['msg']
                        }
                        r = BLL_DocGroupSections.attach_sections(j_body)

                        for k in range(range_start, range_stop):
                            doc_data = {
                                "doc_name": "doc" + str((i * 10000) + k)
                            }
                            r6 = BLL_Documents.create_document(
                                doc_data=doc_data)

                            j_body = {
                                "doc_id": r6['msg'],
                                "append_doc_id": r5['msg']
                            }
                            r = BLL_DocGroupSections.attach_sections(j_body)
예제 #4
0
def test_create_group(inc_num):
    # create a document
    doc_data = {"doc_name": "new doc 2:22_" + inc_num}
    r = BLL_Documents.create_document(doc_data=doc_data)
    doc_id = r["msg"]
    print("doc_id = {}".format(doc_id))
    # create a section
    section_data = {"sec_date_in": "1/1/2019", "sec_text": "new section 1"}
    r = BLL_Sections.create_section(section_data)
    sec_id = r["msg"]
    print("sec_id = {}".format(sec_id))

    # create a group
    group_data = {"doc_id": doc_id, "sec_id": sec_id}
    r = BLL_Groups.create_group(group_data)
    group_id = r["msg"]
    print("created group" + group_id)
예제 #5
0
def test_create_multiple_doc_parents():

    # get a random existing document
    docs = BLL_Documents.get_documents()
    y = random.randint(1, len(docs))
    aDoc = docs[y]
    aDoc_dict = aDoc.to_dict()
    doc_id = aDoc_dict['doc_id']

    y = random.randint(1, len(docs))
    aDoc = docs[y]
    aDoc_dict = aDoc.to_dict()
    parent_id = aDoc_dict['doc_id']

    doc_data = {
        "doc_id": doc_id,
        "parent_id": parent_id,
        "relationship": "copy"
    }

    r = BLL_Doc_Parent.create_doc_parent(doc_data)
    print(r)
예제 #6
0
def test_get_doc_by_name():
    doc_name = 'abc'
    doc = BLL_Documents.single_document_by_name(doc_name)
    if not doc:
        print('could not find {}'.format(doc_name))
예제 #7
0
def test_update_doc(doc_name):
    doc_data = {"doc_id": "1001", "doc_name": "changed name2"}
    r = BLL_Documents.update_document(doc_id='1001', doc_data=doc_data)
    print(r)
예제 #8
0
def test_create_doc():
    doc_data = {"doc_name": "new doc 2:22"}
    r = BLL_Documents.create_document(doc_data=doc_data)
    print(r)
예제 #9
0
def test_get_all_documents():
    docs = BLL_Documents.get_documents()
    print('{} docs found'.format(len(docs)))
예제 #10
0
def update_document(request: Request):
    doc_id = request.matchdict.get('doc_id')
    doc_data = request.json_body
    r = BLL_Documents.update_document(doc_id, doc_data)

    return Response(status=200, body=r)
예제 #11
0
def create_document(request: Request):
    doc_data = request.json_body
    r = BLL_Documents.create_document(doc_data)

    return Response(status=r["status"], body=r["msg"])
예제 #12
0
def single_document_by_name(request: Request):
    doc_name = request.matchdict.get('doc_name')
    doc = BLL_Documents.single_document_by_name(doc_name)

    return doc
예제 #13
0
def single_document_by_id(request: Request):
    doc_id = request.matchdict.get('doc_id')
    doc = BLL_Documents.single_document(doc_id)

    return doc
예제 #14
0
def all_documents(_):
    docs = BLL_Documents.get_documents()

    return docs