コード例 #1
0
    def test_run_netman_with_a_gunicorn_wrapper(self):
        with GunicornNetmanTestApp() as partial_client:
            client = partial_client(get_available_switch("cisco"))

            create_session(client, "my_session")

            result = client.delete("/switches-sessions/my_session")
            assert_that(result.status_code, is_(204), result.text)
コード例 #2
0
    def test_run_netman_with_a_gunicorn_wrapper(self):
        with GunicornNetmanTestApp() as partial_client:
            client = partial_client(get_available_switch("cisco"))

            create_session(client, "my_session")

            result = client.delete("/switches-sessions/my_session")
            assert_that(result.status_code, is_(204), result.text)
コード例 #3
0
    def test_parameters_can_be_passed_through_the_command_line(self):
        with GunicornNetmanTestApp() as partial_client:
            client = partial_client(get_available_switch("brocade"))
            start_time = time.time()

            create_session(client, "session_timeouting")

            create_session(client, "session_taking_over")

            result = client.delete("/switches-sessions/session_taking_over")
            assert_that(result.status_code, is_(204), result.text)

            assert_that(time.time() - start_time, is_(less_than(3)))
コード例 #4
0
    def test_parameters_can_be_passed_through_the_command_line(self):
        with GunicornNetmanTestApp() as partial_client:
            client = partial_client(get_available_switch("brocade"))
            start_time = time.time()

            create_session(client, "session_timeouting")

            create_session(client, "session_taking_over")

            result = client.delete("/switches-sessions/session_taking_over")
            assert_that(result.status_code, is_(204), result.text)

            assert_that(time.time() - start_time, is_(less_than(3)))
コード例 #5
0
ファイル: session_test.py プロジェクト: simon-begin/netman
    def test_creating_two_duplicate_sessions_returns_409(self):
        with NetmanTestApp() as partial_client:
            client = partial_client(get_available_switch("dell"))

            result = create_session(client, "i_love_sessions")

            first_session_id = result.json()['session_id']

            result = client.post("/switches-sessions/{}".format(first_session_id),
                                 data=json.dumps({"hostname": client.switch.hostname}))
            assert_that(result.status_code, is_(409), result.text)
コード例 #6
0
ファイル: session_test.py プロジェクト: simon-begin/netman
    def test_sessions_can_time_out(self):
        with NetmanTestApp() as partial_client:
            client = partial_client(get_available_switch("brocade"))

            result = create_session(client, "i_love_sessions")

            session_id = result.json()['session_id']

            time.sleep(2)

            result = client.post("/switches-sessions/" + session_id + "/actions", data='start_transaction')
            assert_that(result.json().get("error"), is_('Session "i_love_sessions" not found.'))
            assert_that(result.status_code, is_(404), 'Session should have timed out')
コード例 #7
0
ファイル: session_test.py プロジェクト: simon-begin/netman
    def test_creating_commit_deleting_session_works(self):
        with NetmanTestApp() as partial_client:
            client = partial_client(get_available_switch("cisco"))

            result = create_session(client, "i_love_sessions")
            session_id = result.json()['session_id']
            client.post("/switches-sessions/" + session_id + "/actions", data='start_transaction')

            result = client.post("/switches-sessions/" + session_id + "/actions", data='commit')
            assert_that(result.status_code, is_(204), result.text)

            client.post("/switches-sessions/" + session_id + "/actions", data='end_transaction')
            result = client.delete("/switches-sessions/" + session_id)
            assert_that(result.status_code, is_(204), result.text)