def test_create_section():
    # section_data = request.json_body
    section_data = {"sec_date_in": "1/1/2019", "sec_text": "new section 1"}
    sec_id = BLL_Sections.create_section(section_data)
    print(sec_id)

    return sec_id
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)
def test_edit_section():
    section_data = {
        "sec_id": "8c064d9a-f689-4ab1-bbed-1652623aa1c7",
        "sec_text": "new section 1a",
        "sec_date_in": "2019-01-01"
    }
    r = BLL_Sections.update_section("8c064d9a-f689-4ab1-bbed-1652623aa1c7",
                                    section_data)
    print(r)
def edit_section():
    sec_id = request.form.get('sec_id')

    section_dict = BLL_Sections.single_section(sec_id)

    section = section_dict['msg']
    section_data = {"sec_id": section.sec_id, "sec_text":section.sec_text}

    return section_data
def save_section():
    sec_id = request.form.get('sec_id')
    sec_text = request.form.get('sec_text')
    sec_editor = request.form.get('editor')
    sec_text = request.form.get('aaa')
    sec_date_in = request.form.get('sec_date_in')
    sec_data = {'sec_id': sec_id, 'sec_text': sec_text, 'sec_date_in': sec_date_in}

    msg_dict = BLL_Sections.update_section(sec_id,sec_data)
    # section_data = {"sec_id": section.sec_id, "sec_text":section.sec_text}

    return msg_dict
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)
def test_get_sections_by_doc(doc_id):
    sections = BLL_Sections.get_sections_by_doc(doc_id)
    print('found {} sections'.format(len(sections)))
    return None
def test_get_all_sections():
    sections = BLL_Sections.get_sections()
    print('found {} sections'.format(len(sections)))
    return None