コード例 #1
0
ファイル: test_server.py プロジェクト: NickVolynkin/vmmaster
    def test_server_deleting_session_on_client_connection_drop(self):
        """
        - create vmmaster session
        - close the connection
        - try to get vmmaster session
        Expected: vmmaster session deleted
        """
        from core.sessions import Session
        session = Session()

        with patch('core.sessions.Sessions.get_session',
                   Mock(return_value=session)), patch.object(Session,
                                                             'close') as mock:
            get_session_request(self.address, session.id)

        self.assertTrue(mock.called)
        session.close()
コード例 #2
0
ファイル: test_server.py プロジェクト: NickVolynkin/vmmaster
 def test_get_non_existing_session(self):
     """
     - try to get session from empty pool
     Expected: exception
     """
     session_id = uuid4()
     with patch('flask.current_app.database.get_session',
                Mock(return_value=None)):
         response = get_session_request(self.address, session_id)
     self.assertTrue(
         "SessionException: There is no active session %s (Unknown session)"
         % session_id in response.content)
コード例 #3
0
ファイル: test_server.py プロジェクト: NickVolynkin/vmmaster
    def test_check_timer_for_session_activity(self):
        """
        - exception while waiting endpoint
        Expected: session was created, session_step was created
        """
        def get_vm_mock(arg):
            yield Mock(name="test_vm_1", ip="127.0.0.1")

        with patch('vmpool.endpoint.get_vm', Mock(side_effect=get_vm_mock)):
            response = new_session_request(self.address, self.desired_caps)

        self.assertEqual(200, response.status)

        response = get_session_request(self.address, 1)
        self.assertIn(
            "SessionException: There is no active session 1 (Unknown session)",
            response.content)
コード例 #4
0
ファイル: test_server.py プロジェクト: NickVolynkin/vmmaster
    def test_get_closed_session(self):
        """
        - succeed existing session
        - try to get this session
        Expected: session exception without any reason
        """
        from core.sessions import Session
        session = Session()
        session.selenium_session = '1'
        session.succeed()

        with patch('flask.current_app.database.get_session',
                   Mock(return_value=session)):
            response = get_session_request(self.address, session.id)
        self.assertIn(
            "SessionException: There is no active session %s" % session.id,
            response.content)
        session.close()