class TestLogin(unittest.TestCase):
    def setUp(self):
        cfg_info = NewConfig()
        self.common, self.headers = cfg_info.get_info()
        self.t = LoginApi()

    def test_login_success(self):
        access_token = self.t.get_access_token(self.common, self.headers)
        result = self.t.check_uname(self.common, self.headers, access_token)
        assert self.common.get('uname').split("@")[0] in result

    def test_login_fail_with_wrong_uname_right_pwd(self):
        self.common.update({'uname': self.common.get('uname') + "1"})
        access_token = self.t.get_access_token(self.common, self.headers)
        # result = self.t.check_uname(self.common, self.headers, access_token)
        assert access_token == None

    def test_login_fail_with_right_uname_wrong_pwd(self):
        self.common.update({'pwd': str(self.common.get('pwd')) + "1"})
        access_token = self.t.get_access_token(self.common, self.headers)
        # result = self.t.check_uname(self.common, self.headers, access_token)
        assert access_token == None

    def test_login_fail_with_wrong_uname_wrong_pwd(self):
        self.common.update({'uname': self.common.get('uname') + "1"})
        self.common.update({'pwd': str(self.common.get('pwd')) + "1"})
        access_token = self.t.get_access_token(self.common, self.headers)
        assert access_token == None

    def tearDown(self):
        pass
Esempio n. 2
0
 def setUp(self):
     cfg_info = NewConfig()
     self.common, self.headers = cfg_info.get_info(devices_name="vivox6")
     self.t = LoginApi()
     self.access_token = self.t.get_access_token(self.common, self.headers)
     self.s_detail = GetServiceDetail(self.common, self.headers,
                                      self.access_token)
     self.response = self.s_detail.get_service_detail()
Esempio n. 3
0
    def setUp(self):
        cfg_info = NewConfig()
        self.common, self.headers = cfg_info.get_info(devices_name="vivox6")
        self.t = LoginApi()
        self.access_token = self.t.get_access_token(self.common, self.headers)
        self.ex_p90 = PostExperience(self.common, self.headers, self.access_token)

        self.services_info = GetServiceInfo(self.common, self.headers, self.access_token)
        self.task_info = GetTaskInfo2(self.common, self.headers, self.access_token)

        self.at_result = GetAllArtTrainResultAnswer(self.common, self.headers, self.access_token)
Esempio n. 4
0
 def setUp(self):
     cfg_info = NewConfig()
     self.common, self.headers = cfg_info.get_info()
     t = LoginApi()
     self.access_token = t.get_access_token(self.common, self.headers)
     self.sevicesID = t.get_user_study_center(self.common, self.headers,
                                              self.access_token)
     get_measure_id = GetMeasureInfo(self.common, self.headers,
                                     self.access_token)
     _, self.mID, _ = get_measure_id.get_sys_id(self.sevicesID)
     self.report = GetMeasureReport(self.common, self.headers,
                                    self.access_token)
    def setUpClass(cls):
        cfg_info = NewConfig()
        common, headers = cfg_info.get_info(devices_name="vivox6")
        t = LoginApi()
        cls.access_token = t.get_access_token(common, headers)
        cls.sevicesID = t.get_user_study_center(common, headers, cls.access_token)
        cls.sys = GetMeasureInfo(common, headers, cls.access_token)

        cls.mWords = GetMeasureWords(common, headers, cls.access_token)
        cls.word_postAnswer = PostMeasureWords(common, headers, cls.access_token)

        cls.mGra = GetMeasureGra(common, headers, cls.access_token)
        cls.gra_postAnswer = PostMeasureGra(common, headers, cls.access_token)

        cls.mLis = GetMeasureListen(common, headers, cls.access_token)
        cls.lis_postAnswer = PostMeasureLis(common, headers, cls.access_token)

        cls.mRead = GetMeasureRead(common, headers, cls.access_token)
        cls.rid_postAnswer = PostMeasureRead(common, headers, cls.access_token)

        cls.mWrite = GetMeasureWrite(common, headers, cls.access_token)
        cls.wri_postAnswer = PostMeasureWrite(common, headers, cls.access_token)
Esempio n. 6
0
class TestExp90(unittest.TestCase):
    def setUp(self):
        cfg_info = NewConfig()
        self.common, self.headers = cfg_info.get_info(devices_name="vivox6")
        self.t = LoginApi()
        self.access_token = self.t.get_access_token(self.common, self.headers)
        self.ex_p90 = PostExperience(self.common, self.headers, self.access_token)

        self.services_info = GetServiceInfo(self.common, self.headers, self.access_token)
        self.task_info = GetTaskInfo2(self.common, self.headers, self.access_token)

        self.at_result = GetAllArtTrainResultAnswer(self.common, self.headers, self.access_token)

    def test_0_exp_90_success(self):
        response = self.ex_p90.post_experience(p="P90")
        code = response.get('code')
        datas = response.get('data')
        msg = response.get('message')
        self.assertEqual(code, 0)
        self.assertEqual(datas.get('nextAction'), 0)
        self.assertTrue(msg == "success")

    def test_1_exp_90_fail_with_P900(self):
        response = self.ex_p90.post_experience(p="P900")
        code = response.get('code')
        msg = response.get('message')
        self.assertEqual(code, 500)
        self.assertEqual(msg, '服务器错误')

    def test_2_to_finih_article_tarin(self):
        datas = self.task_info.get_all_tasks_id("P90")
        for tasks in datas:
            if tasks.get("RID"):
                for task in tasks.get("RID"):
                    taskID = task.get("taskID")
                    groupID = task.get("groupID")
                    practiceType = task.get('practiceType')
                    finish_rid(task, self.common, self.headers, self.access_token)
                    if practiceType == 15:
                        result_datas = self.at_result.get_all_art_train_result_answer(groupID=groupID, taskID=taskID)
                        # content = result_datas.get('data').get('questGuide')[0].get('originalTextCN')
                        # self.assertEqual(len(content), 4)
                        self.assertEqual(result_datas.get('code'), 0)
                        self.assertEqual(result_datas.get('data').get('score'), 100)

    def tearDown(self):
        pass
Esempio n. 7
0
class TestGetServicesDetail(unittest.TestCase):
    def setUp(self):
        cfg_info = NewConfig()
        self.common, self.headers = cfg_info.get_info(devices_name="vivox6")
        self.t = LoginApi()
        self.access_token = self.t.get_access_token(self.common, self.headers)
        self.s_detail = GetServiceDetail(self.common, self.headers,
                                         self.access_token)
        self.response = self.s_detail.get_service_detail()

    def test_services_detail_shareEnabled(self):
        assert self.response.get('shareEnabled') == True

    def test_services_detail_servicePrice(self):
        assert self.response.get('servicePrice') == '2598'

    def test_services_detail_P150(self):
        assert self.response.get('serviceID') == 'P150'

    def test_services_detail_short_name(self):
        assert self.response.get('serviceShortName') == '150 分精英班'

    def tearDown(self):
        pass
            t = threading.Thread(target=finish_lis,
                                 args=(task, common, headers, access_token))
            t.start()
    if datas.get("WRI"):
        for task in datas.get("WRI"):
            t = threading.Thread(target=finish_wri,
                                 args=(task, common, headers, access_token))
            t.start()


if __name__ == '__main__':
    cfg_info = NewConfig()
    devices = cfg_info.get_info('vivox6')
    common, headers = cfg_info.get_info("vivox6")
    print(common, headers)
    t = LoginApi()
    access_token = t.get_access_token(common, headers)
    print("access_token:".capitalize(), access_token)
    while True:
        try:
            step1 = GetServiceInfo(common, headers, access_token)
            step1_ids = step1.get_service_id()
            servicesID, _, _, = step1_ids
            print("Step1 return:", step1_ids)
            step2 = GetTaskInfo(common, headers, access_token)
            step2_ids = step2.get_task_id(servicesID)
            print("step2_ids", step2_ids)
            scheduleID, _, all_currStatus = step2_ids
            print("all_currStatus", all_currStatus)
            all_currStatuses = []
            for c in all_currStatus:
Esempio n. 9
0
from testcase.api.measure.listen.getMeasureListen_step1 import GetMeasureListen
from testcase.api.measure.listen.postmeasureListen_step2 import PostMeasureLis
from testcase.api.measure.read.getMeasureRead_step1 import GetMeasureRead
from testcase.api.measure.read.postmeasureRead_step2 import PostMeasureRead
from testcase.api.measure.write.getMeasureWrite_step1 import GetMeasureWrite
from testcase.api.measure.write.postmeasureWrite_step2 import PostMeasureWrite
from utils.config import NewConfig


if __name__ == '__main__':
    cfg_info = NewConfig()
    devices = cfg_info.get_info('vivox6')
    common, headers = cfg_info.get_info("vivox6")
    # print("COMMON", common)
    # {'uname': '*****@*****.**', 'pwd': 111111, 'loginUrl': 'https://proxy.langlib.com', 'loginProxy': 'proxy.langlib.com', 'baseUrl': 'https://appncee.langlib.com', 'baseProxy': 'appncee.langlib.com'}
    t = LoginApi()
    access_token = t.get_access_token(common, headers)
    # print(access_token)
    result = t.check_uname(common, headers, access_token)
    # print(result)
    sevicesID = t.get_user_study_center(common, headers, access_token)
    print(sevicesID)
    sys = GetMeasureInfo(common, headers, access_token)
    print("sys", sys)
    sysId, measureID, studyType = sys.get_sys_id(sevicesID)
    if studyType == "VOC":
        mWords = GetMeasureWords(common,headers, access_token)
        currStatus, measureId, currQuestIdx, data = mWords.get_measure_words(sysId)
        all_curr, all_right = mWords.get_all_right_answer(studyType, data)
        print(all_curr, len(all_curr))
        print(all_right, len(all_right))
class TestExp120(unittest.TestCase):
    def setUp(self):
        cfg_info = NewConfig()
        self.common, self.headers = cfg_info.get_info(devices_name="vivox6")
        self.t = LoginApi()
        self.access_token = self.t.get_access_token(self.common, self.headers)
        self.ex_p90 = PostExperience(self.common, self.headers, self.access_token)

        self.services_info = GetServiceInfo(self.common, self.headers, self.access_token)
        self.task_info = GetTaskInfo2(self.common, self.headers, self.access_token)

        self.at_result = GetAllArtTrainResultInfo(self.common, self.headers, self.access_token)
        self.sa_result = GetAllSenAnaResultInfo(self.common, self.headers, self.access_token)
        self.ef_result = GetAllErrorFindResultInfo(self.common, self.headers, self.access_token)

    def test_0_exp_120_success(self):
        response = self.ex_p90.post_experience(p="P120")
        code = response.get('code')
        datas = response.get('data')
        msg = response.get('message')
        self.assertEqual(code, 0)
        self.assertEqual(datas.get('nextAction'), 0)
        self.assertTrue(msg == "success")

    def test_1_exp_120_fail_with_P900(self):
        response = self.ex_p90.post_experience(p="P900")
        code = response.get('code')
        msg = response.get('message')
        self.assertEqual(code, 500)
        self.assertEqual(msg, '服务器错误')

    def test_2_to_finih_sa(self):
        datas = self.task_info.get_all_tasks_id("P120")
        for tasks in datas:
            if tasks.get("RID"):
                for task in tasks.get("RID"):
                    taskID = task.get("taskID")
                    groupID = task.get("groupID")
                    practiceType = task.get('practiceType')
                    finish_rid(task, self.common, self.headers, self.access_token)
                    if practiceType == 13:
                        result_datas = self.sa_result.get_all_sen_ana_result_info(groupID=groupID, taskID=taskID)
                        self.assertEqual(result_datas.get('code'), 0)
                        self.assertEqual(result_datas.get('data').get('score'), 100)
                    if practiceType == 15:
                        result_datas = self.at_result.get_all_art_train_result_info(groupID=groupID, taskID=taskID)
                        self.assertEqual(result_datas.get('code'), 0)
                        self.assertEqual(result_datas.get('data').get('score'), 100)
                        self.assertEqual(result_datas.get('data').get('questGuide'), 0)

    def test_3_to_finih_error_find(self):
        datas = self.task_info.get_all_tasks_id("P120")
        for tasks in datas:
            if tasks.get("GRA"):
                for task in tasks.get("GRA"):
                    taskID = task.get("taskID")
                    groupID = task.get("groupID")
                    practiceType = task.get('practiceType')
                    finish_gra(task, self.common, self.headers, self.access_token)
                    if practiceType == 8:
                        result_datas = self.ef_result.get_all_error_find_result_info(taskID=taskID, groupID=groupID)
                        score = (result_datas.get('data').get('questGuide')[0].get("avgScore"))
                        self.assertEqual(result_datas.get('code'), 0)
                        self.assertEqual(result_datas.get('message').upper(),"SUCCESS")
                        self.assertEqual(score, 100)

    def tearDown(self):
        pass
 def setUp(self):
     cfg_info = NewConfig()
     self.common, self.headers = cfg_info.get_info()
     self.t = LoginApi()