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
Ejemplo n.º 2
0
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))
        postAnswer = PostMeasureWords(common, headers, access_token)
        final_result = postAnswer.post_measure_words(measureID, all_curr, all_right)
        if final_result: