Commit cf00d3e5 authored by Mikhail Karnevskiy's avatar Mikhail Karnevskiy
Browse files

Fix numeric next stream

parent 38e81c23
......@@ -74,10 +74,11 @@ def get_new_stream(stream, receiver_stream_list, metadata_stream_list,
elif naming_scheme == 'numeric':
receiver_stream_list = [x['name'] for x in receiver_stream_list]
metadata_stream_list = [x['name'] for x in metadata_stream_list]
max_stream_number = max_stream(receiver_stream_list)
try:
if (int(stream) < max_stream_number
and max_stream_number in metadata_stream_list):
and str(max_stream_number) in metadata_stream_list):
return str(int(stream) + 1)
except ValueError:
log.warning(
......
......@@ -43,14 +43,12 @@ def test_get_next_by_date(receiver_streams, sender_streams):
def test_get_next_by_number(receiver_streams, sender_streams):
stream = receiver_streams[0]['name']
expected = ['1', '2', '3', '4', '5']
stream = receiver_streams[1]['name']
expected = ['2', '3', '4', '5', None]
for i in range(5):
new_stream = get_new_stream(stream, receiver_streams, receiver_streams,
sender_stream_list=sender_streams, naming_scheme='numeric')
stream = new_stream
assert new_stream == expected[i]
stream = get_new_stream(stream, receiver_streams, receiver_streams,
sender_stream_list=sender_streams, naming_scheme='numeric')
assert stream == expected[i]
def test_get_next_by_name(receiver_streams, sender_streams):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment