def test_proxy_path_smth(self, mock_auctions_server, expected_result):

        output = auctions_proxy(AUCTION_DOC_ID, 'smth_path')

        # assertion block
        mock_auctions_server['patch_abort'].assert_called_once_with(404)
        assert output == expected_result
    def test_proxy_path_smth(self, mock_auctions_server, expected_result):

        output = auctions_proxy(AUCTION_DOC_ID, 'smth_path')

        # assertion block
        mock_auctions_server['patch_abort'].assert_called_once_with(404)
        assert output == expected_result
    def test_proxy_path_login_2(self, mock_auctions_server, expected_result):

        output = auctions_proxy(AUCTION_DOC_ID, 'login')

        # assertion block
        mock_auctions_server['proxy_mappings'].get.assert_called_once_with(
            AUCTION_DOC_ID,
            proxy_data_proxy_path['get_mapping'],
            (proxy_data_proxy_path['server_config_redis'],
             AUCTION_DOC_ID, False), max_age=Any(int)
        )
        mock_auctions_server['patch_abort'].assert_called_once_with(404)
        assert output == expected_result
    def test_proxy_path_login_2(self, mock_auctions_server, expected_result):

        output = auctions_proxy(AUCTION_DOC_ID, 'login')

        # assertion block
        mock_auctions_server['proxy_mappings'].get.assert_called_once_with(
            AUCTION_DOC_ID,
            proxy_data_proxy_path['get_mapping'],
            (proxy_data_proxy_path['server_config_redis'], AUCTION_DOC_ID,
             False),
            max_age=Any(int))
        mock_auctions_server['patch_abort'].assert_called_once_with(404)
        assert output == expected_result
    def test_proxy_path_event_source(self, mock_auctions_server,
                                     patch_response):

        manager = MagicMock()
        manager.attach_mock(mock_auctions_server['patch_PySse'], 'patch_PySse')
        manager.attach_mock(mock_auctions_server['patch_add_message'],
                            'patch_add_message')
        manager.attach_mock(patch_response['patch_resp'], 'patch_resp')

        output = auctions_proxy(AUCTION_DOC_ID, 'event_source')

        # assertion block
        expected_calls = [
            call.patch_PySse(),
            call.patch_add_message('Close', 'Disable'),
            call.patch_resp(mock_auctions_server['patch_PySse'].return_value,
                            mimetype='text/event-stream',
                            content_type='text/event-stream')
        ]
        assert manager.mock_calls == expected_calls
        assert output == patch_response['result']
    def test_proxy_path_event_source(self, mock_auctions_server,
                                     patch_response):

        manager = MagicMock()
        manager.attach_mock(mock_auctions_server['patch_PySse'],
                            'patch_PySse')
        manager.attach_mock(mock_auctions_server['patch_add_message'],
                            'patch_add_message')
        manager.attach_mock(patch_response['patch_resp'], 'patch_resp')

        output = auctions_proxy(AUCTION_DOC_ID, 'event_source')

        # assertion block
        expected_calls = [call.patch_PySse(),
                          call.patch_add_message('Close', 'Disable'),
                          call.patch_resp(
                              mock_auctions_server['patch_PySse'].return_value,
                              mimetype='text/event-stream',
                              content_type='text/event-stream'
                          )]
        assert manager.mock_calls == expected_calls
        assert output == patch_response['result']
    def test_proxy_with_proxy_path(self, mock_auctions_server, path,
                                   expected_result):

        output = auctions_proxy(AUCTION_DOC_ID, path)

        # assertion block
        mock_auctions_server['proxy_mappings'].get.assert_called_once_with(
            AUCTION_DOC_ID,
            proxy_data_proxy_path['get_mapping'],
            (proxy_data_proxy_path['server_config_redis'], AUCTION_DOC_ID,
             False),
            max_age=Any(int))
        mock_auctions_server['mock_path_info']\
            .assert_called_once_with('/' + path)
        mock_auctions_server['patch_StreamProxy'].assert_called_once_with(
            proxy_data_proxy_path['proxy_path'],
            auction_doc_id=AUCTION_DOC_ID,
            event_sources_pool=proxy_data_proxy_path['event_sources_pool'],
            event_source_connection_limit=proxy_data_proxy_path[
                'connection_limit'],
            pool=proxy_data_proxy_path['proxy_connection_pool'],
            backend='gevent')
        assert output == expected_result
    def test_proxy_with_proxy_path(self, mock_auctions_server, path,
                                   expected_result):

        output = auctions_proxy(AUCTION_DOC_ID, path)

        # assertion block
        mock_auctions_server['proxy_mappings'].get.assert_called_once_with(
            AUCTION_DOC_ID,
            proxy_data_proxy_path['get_mapping'],
            (proxy_data_proxy_path['server_config_redis'],
             AUCTION_DOC_ID, False), max_age=Any(int)
        )
        mock_auctions_server['mock_path_info']\
            .assert_called_once_with('/' + path)
        mock_auctions_server['patch_StreamProxy'].assert_called_once_with(
            proxy_data_proxy_path['proxy_path'],
            auction_doc_id=AUCTION_DOC_ID,
            event_sources_pool=proxy_data_proxy_path['event_sources_pool'],
            event_source_connection_limit=
                proxy_data_proxy_path['connection_limit'],
            pool=proxy_data_proxy_path['proxy_connection_pool'],
            backend='gevent'
        )
        assert output == expected_result