Пример #1
0
    def test_add_studnet(self):
        name = 'mew'
        gender = Gender.male
        grade = '2014'
        password = '******'
        mobile = '13000000000'

        id_ = Student.add(name, gender, grade, StudentType.double_major,
                          password, mobile, AccountStatus.need_verify)

        student = Student.get(id_)

        assert student
        assert student.id

        account = Account.get(id_)

        assert account
        assert account.id == id_

        assert student.password != password
        assert student.need_verify()

        assert student.mobile == mobile

        student.to_normal()
        student = Student.get(id_)
        assert student.is_normal()
Пример #2
0
    def test_password(self):
        name = 'seeyoon'
        gender = Gender.male
        grade = '2014'
        password = '******'
        mobile = '13000000001'

        id_ = Student.add(name, gender, grade, StudentType.double_major,
                          password, mobile, AccountStatus.need_verify)

        student = Student.get(id_)
        assert student.verify_password(password)
        assert not student.verify_password('wrongpasswd')
Пример #3
0
    def test_change_mobile(self):
        name = 'tim'
        gender = Gender.male
        grade = '2014'
        password = '******'
        mobile = '13000000002'

        id_ = Student.add(name, gender, grade, StudentType.double_major,
                          password, mobile, AccountStatus.need_verify)

        student = Student.get(id_)

        new_mobile = '15600000000'
        student.change_mobile(new_mobile)
        assert student.mobile == new_mobile
Пример #4
0
    def _add_student():
        import random
        from black_market.model.user.student import Student
        from black_market.model.user.consts import Gender, StudentType, AccountStatus
        name = 'mew' + str(random.randint(0, 100)) + str(random.randint(0, 100))
        gender = Gender.male
        grade = '2014'
        password = '******'
        mobile = '1300000' + str(random.randint(0, 9)) + str(random.randint(0, 9)) + \
                 str(random.randint(0, 9)) + str(random.randint(0, 9))

        id_ = Student.add(
            name, gender, grade, StudentType.double_major,
            password, mobile, AccountStatus.need_verify)

        return Student.get(id_)
Пример #5
0
    def test_change_password(self):
        name = 'zhengnan'
        gender = Gender.male
        grade = '2014'
        password = '******'
        mobile = '13000000001'

        id_ = Student.add(name, gender, grade, StudentType.double_major,
                          password, mobile, AccountStatus.need_verify)

        student = Student.get(id_)

        salt = student.salt

        new_password = '******'
        student.change_password(new_password)

        assert student.verify_password(new_password)
        assert not student.verify_password(password)
        assert salt != student.salt