fix: test: test_to_temp_file_content
This commit is contained in:
parent
098d0d5e71
commit
f80e5b241a
@ -393,43 +393,29 @@ def test_is_editor_valid(editor, exp_res):
|
|||||||
def test_to_temp_file_content(url, title_in, tags_in, desc):
|
def test_to_temp_file_content(url, title_in, tags_in, desc):
|
||||||
"""test func."""
|
"""test func."""
|
||||||
import buku
|
import buku
|
||||||
res = buku.to_temp_file_content(url, title_in, tags_in, desc)
|
if desc is None:
|
||||||
lines = [
|
desc_text = '\n'
|
||||||
'# Lines beginning with "#" will be stripped.',
|
elif desc == '':
|
||||||
'# Add URL in next line (single line).',
|
desc_text = '-'
|
||||||
'# Add TITLE in next line (single line). Leave blank to web fetch, "-" for no title.',
|
else:
|
||||||
'# Add comma-separated TAGS in next line (single line).',
|
desc_text = desc
|
||||||
'# Add COMMENTS in next line(s).',
|
title_in = ''
|
||||||
]
|
|
||||||
idx_offset = 0
|
|
||||||
# url
|
|
||||||
if url is not None:
|
|
||||||
lines.insert(2, url)
|
|
||||||
idx_offset += 1
|
|
||||||
if title_in is None:
|
if title_in is None:
|
||||||
title_in = ''
|
title_in = ''
|
||||||
elif title_in == '':
|
elif title_in == '':
|
||||||
title_in = '-'
|
title_in = '-'
|
||||||
else:
|
res = buku.to_temp_file_content(url, title_in, tags_in, desc)
|
||||||
pass
|
lines = """# Lines beginning with "#" will be stripped.
|
||||||
|
# Add URL in next line (single line).{}
|
||||||
# title
|
# Add TITLE in next line (single line). Leave blank to web fetch, "-" for no title.{}
|
||||||
lines.insert(idx_offset + 3, title_in)
|
# Add comma-separated TAGS in next line (single line).{}
|
||||||
idx_offset += 1
|
# Add COMMENTS in next line(s). Leave blank to web fetch, "-" for no comments.{}""".format(
|
||||||
|
''.join(['\n', url]) if url is not None else '',
|
||||||
# tags
|
''.join(['\n', title_in]) if title_in else '\n',
|
||||||
lines.insert(idx_offset + 4, tags_in.strip(buku.DELIM))
|
''.join(['\n', ','.join([x for x in tags_in.split(',') if x])]) if tags_in else '\n',
|
||||||
idx_offset += 1
|
''.join(['\n', desc_text])
|
||||||
|
)
|
||||||
# description
|
assert res == lines
|
||||||
if desc is not None and desc != '':
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
desc = ''
|
|
||||||
lines.insert(idx_offset + 5, desc)
|
|
||||||
|
|
||||||
for idx, res_line in enumerate(res.splitlines()):
|
|
||||||
assert lines[idx] == res_line
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user