当前位置: 首页>>代码示例>>Python>>正文


Python test_helpers.server_post函数代码示例

本文整理汇总了Python中test_helpers.server_post函数的典型用法代码示例。如果您正苦于以下问题:Python server_post函数的具体用法?Python server_post怎么用?Python server_post使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了server_post函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_deauth_valid_token_body

 def test_deauth_valid_token_body(self):
     resp_auth = helpers.server_post("/auth", {"username":"teacher_coll1", "password":"facebees"})
     value = resp_auth.read()
     auth_hash = json.loads(value)
     resp = helpers.server_post("/deauth", auth_hash)
     if helpers.apache_mode():
         self.assertEqual(resp.read(), '')
     else:
         self.assertEqual(resp.read(), '{"deleted": "True"}')
开发者ID:jmorse,项目名称:nemesis,代码行数:9,代码来源:test_deauth.py

示例2: test_registration_name_in_use

def test_registration_name_in_use():
    params = {"username":"teacher_coll1",
              "password":"facebees",
              "first_name":'student2', # student_coll1_2
              "last_name":'student',
              "email":"[email protected]",
              "team":"team-ABC",
              "college":"college-1"}

    r,data = test_helpers.server_post("/registrations", params)

    status = r.status
    assert status == 403, data
    assert 'DETAILS_ALREADY_USED' in data
    assert len(test_helpers.get_registrations()) == 0

    try:
        created = User.create_user('1_ss1')
        assert False, "Should not have created user"
    except:
        pass

    pending = PendingUser('1_ss1')
    assert not pending.in_db

    test_helpers.assert_no_emails()
开发者ID:PeterJCLaw,项目名称:nemesis,代码行数:26,代码来源:test_registrations.py

示例3: test_post_teacher_other_student

def test_post_teacher_other_student():
    params = {"username":"teacher_coll2",
              "password":"noway",
              }
    r,data = test_helpers.server_post("/user/student_coll1_1", params)
    status = r.status
    assert status == 403
开发者ID:PeterJCLaw,项目名称:nemesis,代码行数:7,代码来源:test_users_post.py

示例4: test_registration_bad_frist_name

def test_registration_bad_frist_name():
    params = {"username":"teacher_coll1",
              "password":"facebees",
              "first_name":NEW_USER_FNAME,
              "last_name":'2'+NEW_USER_LNAME,
              "email":"[email protected]",
              "team":"team-ABC",
              "college":"college-1"}

    r,data = test_helpers.server_post("/registrations", params)

    assert r.status == 403
    assert 'BAD_LAST_NAME' in data
    assert len(test_helpers.get_registrations()) == 0

    try:
        created = User.create_user('1_rt1')
        assert False, "Should not have created user"
    except:
        pass

    pending = PendingUser('1_rt1')
    assert not pending.in_db

    test_helpers.assert_no_emails()
开发者ID:PeterJCLaw,项目名称:nemesis,代码行数:25,代码来源:test_registrations.py

示例5: test_post_any_blueshirt_can_record_student_media_consent

def test_post_any_blueshirt_can_record_student_media_consent():
    blueshirt_mcf = srusers.user('blueshirt-mcf')
    groups = blueshirt_mcf.groups()
    # Sanity check
    assert set(groups) == set(['mentors', 'media-consent-admin'])

    params = {"username":"blueshirt-mcf",
              "password":"blueshirt",
              "media_consent":'true',
              }

    r, data = test_helpers.server_post("/user/student_coll1_1", params)
    assert r.status == 200, (r.status, data)

    u = User("student_coll1_1")
    assert u.has_media_consent

    ps = test_helpers.last_email()
    toaddr = ps.toaddr
    expected_addr = u.email
    assert toaddr == expected_addr

    vars = ps.template_vars
    first_name = u.first_name
    assert first_name == vars['first_name']

    template = ps.template_name
    assert template == 'ticket_available'

    test_helpers.assert_load_template(template, vars)
开发者ID:PeterJCLaw,项目名称:nemesis,代码行数:30,代码来源:test_users_post.py

示例6: test_registration_email_in_use

def test_registration_email_in_use():
    params = {
        "username": "teacher_coll1",
        "password": "facebees",
        "first_name": NEW_USER_FNAME,
        "last_name": NEW_USER_LNAME,
        "email": "[email protected]",  # student_coll2_2
        "team": "team-ABC",
        "college": "college-1",
    }

    r, data = test_helpers.server_post("/registrations", params)

    assert r.status == 403
    assert "DETAILS_ALREADY_USED" in data
    assert len(test_helpers.get_registrations()) == 0

    try:
        created = User.create_user("1_rt1")
        assert False, "Should not have created user"
    except:
        pass

    pending = PendingUser("1_rt1")
    assert not pending.in_db

    test_helpers.assert_no_emails()
开发者ID:Krenair,项目名称:nemesis,代码行数:27,代码来源:test_registrations.py

示例7: test_post_sets_own_password_and_name

def test_post_sets_own_password_and_name():
    old_password = "blueshirt"
    new_password = 'bacon'
    old_first = "Blue"
    old_last  = "Shirt"

    params = {"username":"blueshirt",
              "password":old_password,
              "new_password":new_password,
              "new_first_name":'new_first',
              "new_last_name":'new_last',
              }

    r,data = test_helpers.server_post("/user/blueshirt", params)
    assert r.status == 200
    assert User("blueshirt")._user.bind(new_password)

    u = User("blueshirt")
    first = u.first_name
    last = u.last_name
    u.set_password(old_password)
    u.set_first_name(old_first)
    u.set_last_name(old_last)
    u.save()

    assert first == 'new_first'
    assert last == 'new_last'
开发者ID:PeterJCLaw,项目名称:nemesis,代码行数:27,代码来源:test_users_post.py

示例8: test_registration_rq_from_student

def test_registration_rq_from_student():
    test_helpers.delete_db()

    params = {
        "username": "student_coll1_1",
        "password": "cows",
        "first_name": "register",
        "last_name": "this.user",
        "email": "[email protected]",
        "team": "team-ABC",
        "college": "college-1",
    }

    r, data = test_helpers.server_post("/registrations", params)
    status = r.status
    assert status == 403
    assert "YOU_CANT_REGISTER_USERS" in data
    assert len(test_helpers.get_registrations()) == 0

    try:
        created = User.create_user("2_rt1")
        assert False, "Should not have created user"
    except:
        pass

    pending = PendingUser("2_rt1")
    assert not pending.in_db

    test_helpers.assert_no_emails()
开发者ID:Krenair,项目名称:nemesis,代码行数:29,代码来源:test_registrations.py

示例9: test_email_change_request

def test_email_change_request():
    """ Test that change requests via POST at /user/ are handled correclty. """
    username = "student_coll1_1"
    old_email = User(username).email
    new_email = "[email protected]"
    params = {"username":"teacher_coll1",
              "password":"facebees",
              "new_email":new_email,
              }

    r,data = test_helpers.server_post("/user/student_coll1_1", params)
    assert r.status == 200, data
    user = User(username)
    assert user.email == old_email

    ps = test_helpers.last_email()
    toaddr = ps.toaddr
    assert toaddr == new_email

    vars = ps.template_vars
    first_name = user.first_name
    assert first_name == vars['name']

    template = ps.template_name
    assert template == 'change_email'

    pe = PendingEmail(username)
    assert pe.in_db
    assert pe.new_email == new_email
开发者ID:Krenair,项目名称:nemesis,代码行数:29,代码来源:test_email_verification.py

示例10: test_deauth_invalid_token_body

 def test_deauth_invalid_token_body(self):
     auth_hash = {"token":sha256(str(random.randint(0,1000000))).hexdigest()}
     resp = helpers.server_post("/deauth", auth_hash)
     if helpers.apache_mode():
         self.assertEqual(resp.read(), '')
     else:
         self.assertEqual(resp.read(), '{"deleted": "False"}')
开发者ID:jmorse,项目名称:nemesis,代码行数:7,代码来源:test_deauth.py

示例11: test_post_blueshirt_own_student

def test_post_blueshirt_own_student():
    params = {"username":"blueshirt",
              "password":"blueshirt",
              }

    r,data = test_helpers.server_post("/user/student_coll1_1", params)
    assert r.status == 200
开发者ID:PeterJCLaw,项目名称:nemesis,代码行数:7,代码来源:test_users_post.py

示例12: test_post_by_blueshirt

    def test_post_by_blueshirt(self):
        params = {"username":"blueshirt",
                  "password":"blueshirt"}

        r, data = test_helpers.server_post("/send-password-reset/student_coll1_1", params)

        self.assertEqual(202, r.status, data)

        user = User('student_coll1_1')

        ps = test_helpers.last_email()
        toaddr = ps.toaddr
        self.assertEqual(user.email, toaddr)

        vars = ps.template_vars
        self.assertEqual(user.first_name, vars['name'], "Wrong first name")
        self.assertEqual('Blue Shirt', vars['requestor_name'], "Wrong requestor name")

        template = ps.template_name
        self.assertEqual('password_reset', template, "Wrong email template")

        test_helpers.assert_load_template(template, vars)

        ppr = PendingPasswordReset('student_coll1_1')
        self.assertTrue(ppr.in_db, "{0} should been in the database.".format(ppr))
        self.assertEqual('blueshirt', ppr.requestor_username, "Wrong requestor username.")

        self.assertIn(ppr.verify_code, vars['password_reset_url'], "Wrong verify code")
开发者ID:PeterJCLaw,项目名称:nemesis,代码行数:28,代码来源:test_send_password_reset.py

示例13: test_user_post_set_password_password

 def test_user_post_set_password_password(self):
     args_hash = {}
     args_hash["token"] = self.auth_hash
     args_hash["password"] = "abc" + str(random.randint(0,10000))
     resp = helpers.server_post("/user/student_coll2_2", args_hash)
     instance = User("student_coll2_2", "../../nemesis/userman")
     bind_result = instance.conn.bind("student_coll2_2", args_hash["password"])
     self.assertTrue(bind_result)
开发者ID:jmorse,项目名称:nemesis,代码行数:8,代码来源:test_user_post.py

示例14: test_post_student_cant_withdraw_other_student

def test_post_student_cant_withdraw_other_student():
    params = {"username":"student_coll1_1",
              "password":"cows",
              "withdrawn":'true',
              }

    r, data = test_helpers.server_post("/user/student_coll1_2", params)
    assert r.status == 403

    assert not User("student_coll1_2").has_withdrawn
开发者ID:PeterJCLaw,项目名称:nemesis,代码行数:10,代码来源:test_users_post.py

示例15: test_team_leader_cant_demote_self

def test_team_leader_cant_demote_self():
    params = {"username": "teacher_coll1",
              "password": "facebees",
              "new_type": "student",
              }

    r,data = test_helpers.server_post("/user/teacher_coll1", params)
    assert r.status == 200

    assert User("teacher_coll1").is_teacher
开发者ID:PeterJCLaw,项目名称:nemesis,代码行数:10,代码来源:test_users_post.py


注:本文中的test_helpers.server_post函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。