Skip to content

Commit

Permalink
Fix DF2 ID format regex pattern bug (#294)
Browse files Browse the repository at this point in the history
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').
  • Loading branch information
yinan-symphony authored Jun 17, 2022
1 parent e172e62 commit ceb223c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion symphony/bdk/core/service/datafeed/datafeed_loop_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down
20 changes: 20 additions & 0 deletions tests/core/service/datafeed/datafeed_loop_v2_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down

0 comments on commit ceb223c

Please sign in to comment.