From f97e0d9ffc21692c72840fd75a90d408ca26b482 Mon Sep 17 00:00:00 2001 From: Lars Date: Thu, 19 Oct 2023 13:48:52 +0200 Subject: [PATCH] Added test cases for #125 --- tests/test_issue_125.py | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 tests/test_issue_125.py diff --git a/tests/test_issue_125.py b/tests/test_issue_125.py new file mode 100644 index 00000000..211a6eb1 --- /dev/null +++ b/tests/test_issue_125.py @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- +# +# Copyright (c) 2016 - 2023 -- Lars Heuer +# All rights reserved. +# +# License: BSD License +# +"""\ +Issue + +Don't include blank vcard/mecard fields. +""" +from __future__ import unicode_literals, absolute_import +import pytest +import segno +from segno import helpers + + +def test_mecard_data(): + mecard = helpers.make_mecard_data(name='Mustermann,Max', phone=[]) + assert 'MECARD:N:Mustermann,Max;;' == mecard + mecard = helpers.make_mecard_data(name='Mustermann,Max', email="") + assert 'MECARD:N:Mustermann,Max;;' == mecard + + +def test_vcard_data(): + res = 'BEGIN:VCARD\r\n' \ + 'VERSION:3.0\r\n' \ + 'N:Mustermann;Max\r\n' \ + 'FN:Max Mustermann\r\n' \ + 'END:VCARD\r\n' + vcard = helpers.make_vcard_data('Mustermann;Max', 'Max Mustermann', phone="") + assert res == vcard + vcard = helpers.make_vcard_data('Mustermann;Max', 'Max Mustermann', email="") + assert res == vcard + vcard = helpers.make_vcard_data('Mustermann;Max', 'Max Mustermann', fax="") + assert res == vcard + + +if __name__ == '__main__': + pytest.main([__file__])