Example #1
0
def f_add_school_class():
    bodyDict = sc.add_school_class(1, '七年级1班', 60)
    class_id = bodyDict['id']
    logger.info(f'----------SETUP添加[1,七年级1班,60]成功,班级id为{class_id}-----------')
    yield class_id
    sc.delete_school_class(class_id)
    logger.info('----------TEARDOWN删除[1,七年级1班,60]成功-----------')
Example #2
0
def driver():
    global _driver
    logger.info('------------open APP------------')
    _driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)
    yield _driver
    logger.info('------------close APP------------')
    _driver.quit()
Example #3
0
 def test_modifyclass1(self, f_add_school_class):
     bodyDict = sc.modify_school_class(f_add_school_class, "啦啦啦", 70)
     logger.info(f"修改id为{f_add_school_class}的班级,班级名称修改为'啦啦啦',人数修改为70")
     assert bodyDict['retcode'] == 0
     classlist_after = sc.list_school_class()['retlist'][0]
     assert classlist_after[
         'name'] == "啦啦啦", f"列表内班级名称为{classlist_after['name']},与预期的班级名称:'啦啦啦'不一致"
Example #4
0
 def test_deleteclass2(self, f_add_school_class):
     bodyDict = sc.delete_school_class(f_add_school_class)
     logger.info(f"删除id为{f_add_school_class}的班级")
     assert bodyDict['retcode'] == 0
     classlist = sc.list_school_class()
     assert classlist['retlist'] == [], f"id 为`{f_add_school_class}`的班级仍然存在"
     logger.info("删除成功后,列表为空")
Example #5
0
def driver():
    global _driver
    logger.info('------------open browser------------')
    _driver = webdriver.Firefox()
    _driver.maximize_window()
    yield _driver
    logger.info('------------close browser------------')
    _driver.quit()
Example #6
0
def f_delete_all_school_classes():
    st.delete_all_school_teachers()
    sc.delete_all_school_classes()
    logger.info('----------SETUP删除所有老师、班级成功-----------')
    yield
    st.delete_all_school_teachers()
    sc.delete_all_school_classes()
    logger.info('----------TEARDOWN删除所有老师、班级成功-----------')
Example #7
0
 def test_addclass1(self, gradeid, name, studentlimit):
     """测试添加班级tc000001"""
     bodyDict = sc.add_school_class(gradeid, name, studentlimit)
     assert bodyDict["retcode"] == 0
     logger.info(f'添加班级:{gradeid, name, studentlimit}成功')
     result = sc.list_school_class(gradeid)
     s_bodyDict = result['retlist'][0]
     assert s_bodyDict['id'] == bodyDict['id']
     assert s_bodyDict['invitecode'] == bodyDict['invitecode']
     sc.delete_school_class(bodyDict["id"])
     logger.info(f'删除班级:{gradeid, name, studentlimit}成功')
Example #8
0
 def test_addclass2(self, f_add_school_class):
     """测试添加班级tc000002"""
     bodyDict = sc.add_school_class(1, '七年级2班', 60)
     assert bodyDict['retcode'] == 0
     logger.info('添加班级:[1, 七年级2班, 60]成功')
     classlist = sc.list_school_class()
     sc.classlist_should_contain(classlist['retlist'], '七年级',
                                 bodyDict['id'], bodyDict['invitecode'],
                                 "七年级2班", 60)
     sc.delete_school_class(bodyDict['id'])
     logger.info('删除班级:[1, 七年级2班, 60]成功')
Example #9
0
def f_add_school_teacher(f_add_school_class):
    bodyDict = st.add_school_teacher("linguowei", "linguowei", cfg.g_math,
                                     f_add_school_class, 15851398151,
                                     "*****@*****.**", "320283828323")
    logger.info(
        '----------SETUP添加老师【"linguowei","linguowei",cfg.g_math,f_add_school_class,15851398151,"*****@*****.**","320283828323"】成功-----------'
    )
    yield bodyDict['id']
    st.delete_school_teacher(bodyDict['id'])
    logger.info(
        '----------TEARDOWN删除老师【"linguowei","linguowei",cfg.g_math,f_add_school_class,15851398151,"*****@*****.**","320283828323"】成功-----------'
    )


# if __name__ == "__main__":
#     f_add_school_class()
Example #10
0
    def classlist_should_contain(self,
                                 classlist,
                                 grade_name,
                                 classid,
                                 invitecode,
                                 classname,
                                 studentlimit,
                                 expectedtimes=1):
        item = {
            "name": classname,
            "grade__name": grade_name,
            "invitecode": invitecode,
            "studentlimit": studentlimit,
            "studentnumber": 0,
            "id": classid,
            "teacherlist": []
        }

        occurTimes = classlist.count(item)
        logger.info('occur {} times'.format(occurTimes))

        if occurTimes != int(expectedtimes):
            raise Exception(f'班级列表包含了{occurTimes}次指定信息,期望包含{expectedtimes}次')
Example #11
0
 def test_modifyclass2(self, f_add_school_class):
     bodyDict = sc.add_school_class(1, "七年级2班", 70)
     assert bodyDict['retcode'] == 0
     logger.info('添加班级:[1, 七年级2班, 60]成功')
     classlist_before = sc.list_school_class()
     modifyDict = sc.modify_school_class(bodyDict['id'], '七年级1班', 60)
     logger.info(f"修改id为{bodyDict['id']}的班级,班级名称修改为'七年级1班',人数修改为60")
     assert modifyDict['retcode'] == 1
     assert modifyDict['reason'] == "duplicated class name"
     classlist_after = sc.list_school_class()
     assert classlist_before == classlist_after, f"修改失败后,列表返回内容发生了变化"
     sc.delete_school_class(bodyDict['id'])
     logger.info('删除班级:[1, 七年级2班, 60]成功')
Example #12
0
def driver():
    global _driver
    global _driver_type
    if _driver_type=="chrome":
        logger.info('------------open browser------------')
        _driver = webdriver.Chrome()
        # _driver.maximize_window()
    else:
        logger.info('------------open browser------------')
        _driver = webdriver.Firefox()
    yield _driver
    logger.info('------------close browser------------')
    _driver.quit()
Example #13
0
def get_current_contents(driver):
    current_content = driver.current_context
    logger.info(f'------------{current_content}------------')
    yield current_content
Example #14
0
def get_contents(driver):
    contents = driver.contexts
    logger.info(f'------------{contents}------------')
    yield contents
Example #15
0
 def test_modifyclass3(self, f_add_school_class):
     bodyDict = sc.modify_school_class(f_add_school_class + 1, "啦啦啦", 70)
     logger.info(f"修改id为{f_add_school_class+1}的班级,班级名称修改为'啦啦啦',人数修改为70")
     assert bodyDict['retcode'] == 404
     assert bodyDict['reason'] == f"id 为`{f_add_school_class+1}`的班级不存在"
def open_driver(dri):
    global _driver
    logger.info('------------open browser------------')
    _driver = webdriver.Chrome()
    BuiltIn().set_global_variable('${%s}' % dri, _driver)
    return _driver
Example #17
0
 def test_deleteclass1(self, f_add_school_class):
     bodyDict = sc.delete_school_class(f_add_school_class + 1)
     logger.info(f"删除id为{f_add_school_class+1}的班级")
     assert bodyDict['retcode'] == 404
     assert bodyDict['reason'] == f"id 为`{f_add_school_class+1}`的班级不存在"
Example #18
0
 def tearDownClass(cls):
     cls.driver.quit()
     logger.info("关闭浏览器")