From ceb223cee8b1eb342aabc86b459a38d9210e54cf Mon Sep 17 00:00:00 2001 From: Yinan Liu <60390925+yinan-symphony@users.noreply.github.com> Date: Fri, 17 Jun 2022 11:17:14 +0200 Subject: [PATCH] Fix DF2 ID format regex pattern bug (#294) The existing feed id does not have the suffix after '_f', which does not matche with the regex pattern. With this commit, the regex pattern will match the existing DF ID as well as the new DF ID value (haveing the suffix after '_f'). --- .../core/service/datafeed/datafeed_loop_v2.py | 2 +- .../service/datafeed/datafeed_loop_v2_test.py | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/symphony/bdk/core/service/datafeed/datafeed_loop_v2.py b/symphony/bdk/core/service/datafeed/datafeed_loop_v2.py index 7bc56d9e..038757f2 100644 --- a/symphony/bdk/core/service/datafeed/datafeed_loop_v2.py +++ b/symphony/bdk/core/service/datafeed/datafeed_loop_v2.py @@ -15,7 +15,7 @@ # DFv2 API authorizes a maximum length for the tag parameter DATAFEED_TAG_MAX_LENGTH = 100 -DATAFEED_V2_ID_PATTERN = re.compile("^[^\\s_]+_f_[^\\s_]+$") +DATAFEED_V2_ID_PATTERN = re.compile("^[^\\s_]+_f(_[^\\s_]+)?$") logger = logging.getLogger(__name__) diff --git a/tests/core/service/datafeed/datafeed_loop_v2_test.py b/tests/core/service/datafeed/datafeed_loop_v2_test.py index b409ffba..d2c5bd05 100644 --- a/tests/core/service/datafeed/datafeed_loop_v2_test.py +++ b/tests/core/service/datafeed/datafeed_loop_v2_test.py @@ -150,6 +150,26 @@ async def test_start_already_started_datafeed_v2_loop_should_throw_error(datafee await datafeed_loop.start() +@pytest.mark.asyncio +async def test_start_old_datafeed_format_exist(datafeed_loop, datafeed_api, read_df_side_effect): + datafeed_api.list_datafeed.return_value = [V5Datafeed(id="abc_f")] + datafeed_api.read_datafeed.side_effect = read_df_side_effect + + await datafeed_loop.start() + + datafeed_api.list_datafeed.assert_called_with( + session_token="session_token", + key_manager_token="km_token", + tag=BOT_USER + ) + assert datafeed_api.read_datafeed.call_args_list[0].kwargs == {"session_token": "session_token", + "key_manager_token": "km_token", + "datafeed_id": "abc_f", + "ack_id": AckId(ack_id="")} + assert datafeed_loop._datafeed_id == "abc_f" + assert datafeed_loop._ack_id == "ack_id" + + @pytest.mark.asyncio async def test_start_datafeed_exist(datafeed_loop, datafeed_api, read_df_side_effect): datafeed_api.list_datafeed.return_value = [V5Datafeed(id="abc_f_def")]