How to use the segno.helpers.make_vcard_data function in segno

To help you get started, we’ve selected a few segno examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github heuer / segno / tests / test_helpers.py View on Github external
def test_photo_uri():
    photo_uris = ('https://www.example.org/image.jpg', 'https://www.example.com/image_another.gif')
    vcard = helpers.make_vcard_data('Doe;John', 'John Doe', photo_uri=photo_uris)
    assert 'BEGIN:VCARD\r\nVERSION:3.0\r\nN:Doe;John\r\nFN:John Doe\r\nPHOTO;VALUE=uri:{0}\r\nPHOTO;VALUE=uri:{1}\r\nEND:VCARD\r\n'.format(*photo_uris) == vcard
    qr_from_data = segno.make_qr(vcard)
    assert qr_from_data
    assert qr_from_data.error == 'L'
    qr_from_vcard = helpers.make_vcard('Doe;John', 'John Doe', photo_uri=photo_uris)
    assert qr_from_vcard
    assert qr_from_vcard.error == 'L'
    assert qr_from_data == qr_from_vcard
github heuer / segno / tests / test_helpers.py View on Github external
vcard = helpers.make_vcard_data('Mustermann;Max', 'Max Mustermann', org='ABC, Inc.')
    assert 'BEGIN:VCARD\r\nVERSION:3.0\r\nN:Mustermann;Max\r\nFN:Max Mustermann\r\nORG:ABC\\, Inc.\r\nEND:VCARD\r\n' == vcard
    vcard = helpers.make_vcard_data('Stevenson;John;Philip,Paul;Dr.;Jr.,M.D.,A.C.P.', 'John Stevenson')
    assert 'BEGIN:VCARD\r\nVERSION:3.0\r\nN:Stevenson;John;Philip,Paul;Dr.;Jr.,M.D.,A.C.P.\r\nFN:John Stevenson\r\nEND:VCARD\r\n' == vcard
    vcard = helpers.make_vcard_data('Doe;John', 'John Doe', street='Street', city='City', zipcode='123456')
    assert 'BEGIN:VCARD\r\nVERSION:3.0\r\nN:Doe;John\r\nFN:John Doe\r\nADR:;;Street;City;;123456;\r\nEND:VCARD\r\n' == vcard
    vcard = helpers.make_vcard_data('Doe;John', 'John Doe', street='123 Main Street', city='Any Town',
                                    region='CA', zipcode='91921-1234', country='Nummerland')
    assert 'BEGIN:VCARD\r\nVERSION:3.0\r\nN:Doe;John\r\nFN:John Doe\r\nADR:;;123 Main Street;Any Town;CA;91921-1234;Nummerland\r\nEND:VCARD\r\n' == vcard
    vcard = helpers.make_vcard_data('Doe;John', 'John Doe', title='Python wrangler')
    assert 'BEGIN:VCARD\r\nVERSION:3.0\r\nN:Doe;John\r\nFN:John Doe\r\nTITLE:Python wrangler\r\nEND:VCARD\r\n' == vcard
    vcard = helpers.make_vcard_data('Doe;John', 'John Doe',
                                    title=['Python wrangler', 'Snake charmer'])
    assert 'BEGIN:VCARD\r\nVERSION:3.0\r\nN:Doe;John\r\nFN:John Doe\r\nTITLE:Python wrangler\r\nTITLE:Snake charmer\r\nEND:VCARD\r\n' == vcard
    photo_uri = 'https://www.example.org/image.jpg'
    vcard = helpers.make_vcard_data('Doe;John', 'John Doe', photo_uri=photo_uri)
    assert 'BEGIN:VCARD\r\nVERSION:3.0\r\nN:Doe;John\r\nFN:John Doe\r\nPHOTO;VALUE=uri:{0}\r\nEND:VCARD\r\n'.format(photo_uri) == vcard
    photo_uris = ('https://www.example.org/image.jpg', 'https://www.example.com/image_another.gif')
    vcard = helpers.make_vcard_data('Doe;John', 'John Doe', photo_uri=photo_uris)
    assert 'BEGIN:VCARD\r\nVERSION:3.0\r\nN:Doe;John\r\nFN:John Doe\r\nPHOTO;VALUE=uri:{0}\r\nPHOTO;VALUE=uri:{1}\r\nEND:VCARD\r\n'.format(*photo_uris) == vcard
github heuer / segno / tests / test_helpers.py View on Github external
def test_vcard_data_note():
    note = 'test cases,; we need more test cases'
    expected_vcard_data = 'BEGIN:VCARD\r\nVERSION:3.0\r\nN:Mustermann;Max\r\nFN:Max Mustermann\r\nNOTE:test cases\\,\\; we need more test cases\r\nEND:VCARD\r\n'
    vcard = helpers.make_vcard_data('Mustermann;Max', 'Max Mustermann', memo=note)
    assert expected_vcard_data == vcard
github heuer / segno / tests / test_helpers.py View on Github external
def test_vcard_data_invalid_bday():
    with pytest.raises(ValueError):
        helpers.make_vcard_data('Mustermann;Max', 'Max Mustermann', birthday='19760919')
    with pytest.raises(ValueError):
        helpers.make_vcard_data('Mustermann;Max', 'Max Mustermann', birthday='1976-09-19TZ')
github heuer / segno / tests / test_helpers.py View on Github external
def test_vcard_data():
    vcard = helpers.make_vcard_data('Mustermann;Max', 'Max Mustermann')
    assert 'BEGIN:VCARD\r\nVERSION:3.0\r\nN:Mustermann;Max\r\nFN:Max Mustermann\r\nEND:VCARD\r\n' == vcard
    vcard = helpers.make_vcard_data('Mustermann;Max', 'Max Mustermann', org='ABC, Inc.')
    assert 'BEGIN:VCARD\r\nVERSION:3.0\r\nN:Mustermann;Max\r\nFN:Max Mustermann\r\nORG:ABC\\, Inc.\r\nEND:VCARD\r\n' == vcard
    vcard = helpers.make_vcard_data('Stevenson;John;Philip,Paul;Dr.;Jr.,M.D.,A.C.P.', 'John Stevenson')
    assert 'BEGIN:VCARD\r\nVERSION:3.0\r\nN:Stevenson;John;Philip,Paul;Dr.;Jr.,M.D.,A.C.P.\r\nFN:John Stevenson\r\nEND:VCARD\r\n' == vcard
    vcard = helpers.make_vcard_data('Doe;John', 'John Doe', street='Street', city='City', zipcode='123456')
    assert 'BEGIN:VCARD\r\nVERSION:3.0\r\nN:Doe;John\r\nFN:John Doe\r\nADR:;;Street;City;;123456;\r\nEND:VCARD\r\n' == vcard
    vcard = helpers.make_vcard_data('Doe;John', 'John Doe', street='123 Main Street', city='Any Town',
                                    region='CA', zipcode='91921-1234', country='Nummerland')
    assert 'BEGIN:VCARD\r\nVERSION:3.0\r\nN:Doe;John\r\nFN:John Doe\r\nADR:;;123 Main Street;Any Town;CA;91921-1234;Nummerland\r\nEND:VCARD\r\n' == vcard
    vcard = helpers.make_vcard_data('Doe;John', 'John Doe', title='Python wrangler')
    assert 'BEGIN:VCARD\r\nVERSION:3.0\r\nN:Doe;John\r\nFN:John Doe\r\nTITLE:Python wrangler\r\nEND:VCARD\r\n' == vcard
    vcard = helpers.make_vcard_data('Doe;John', 'John Doe',
                                    title=['Python wrangler', 'Snake charmer'])
    assert 'BEGIN:VCARD\r\nVERSION:3.0\r\nN:Doe;John\r\nFN:John Doe\r\nTITLE:Python wrangler\r\nTITLE:Snake charmer\r\nEND:VCARD\r\n' == vcard
    photo_uri = 'https://www.example.org/image.jpg'
    vcard = helpers.make_vcard_data('Doe;John', 'John Doe', photo_uri=photo_uri)
    assert 'BEGIN:VCARD\r\nVERSION:3.0\r\nN:Doe;John\r\nFN:John Doe\r\nPHOTO;VALUE=uri:{0}\r\nEND:VCARD\r\n'.format(photo_uri) == vcard
    photo_uris = ('https://www.example.org/image.jpg', 'https://www.example.com/image_another.gif')
    vcard = helpers.make_vcard_data('Doe;John', 'John Doe', photo_uri=photo_uris)
github heuer / segno / tests / test_helpers.py View on Github external
def test_vcard_data_source_url():
    source_url = 'https://example.org/this-is-the-SOURCE-url'
    expected_vcard_data = 'BEGIN:VCARD\r\nVERSION:3.0\r\nN:Mustermann;Max\r\nFN:Max Mustermann\r\nSOURCE:{}\r\nEND:VCARD\r\n'.format(source_url)
    vcard = helpers.make_vcard_data('Mustermann;Max', 'Max Mustermann', source=source_url)
    assert expected_vcard_data == vcard
github heuer / segno / tests / test_helpers.py View on Github external
def test_vcard_data_valid_geo():
    expected_vcard_data = 'BEGIN:VCARD\r\nVERSION:3.0\r\nN:Mustermann;Max\r\nFN:Max Mustermann\r\nGEO:46.235197;8.015445\r\nEND:VCARD\r\n'
    vcard = helpers.make_vcard_data('Mustermann;Max', 'Max Mustermann', lat=46.235197, lng=8.015445)
    assert expected_vcard_data == vcard
github heuer / segno / tests / test_helpers.py View on Github external
def test_vcard_data():
    vcard = helpers.make_vcard_data('Mustermann;Max', 'Max Mustermann')
    assert 'BEGIN:VCARD\r\nVERSION:3.0\r\nN:Mustermann;Max\r\nFN:Max Mustermann\r\nEND:VCARD\r\n' == vcard
    vcard = helpers.make_vcard_data('Mustermann;Max', 'Max Mustermann', org='ABC, Inc.')
    assert 'BEGIN:VCARD\r\nVERSION:3.0\r\nN:Mustermann;Max\r\nFN:Max Mustermann\r\nORG:ABC\\, Inc.\r\nEND:VCARD\r\n' == vcard
    vcard = helpers.make_vcard_data('Stevenson;John;Philip,Paul;Dr.;Jr.,M.D.,A.C.P.', 'John Stevenson')
    assert 'BEGIN:VCARD\r\nVERSION:3.0\r\nN:Stevenson;John;Philip,Paul;Dr.;Jr.,M.D.,A.C.P.\r\nFN:John Stevenson\r\nEND:VCARD\r\n' == vcard
    vcard = helpers.make_vcard_data('Doe;John', 'John Doe', street='Street', city='City', zipcode='123456')
    assert 'BEGIN:VCARD\r\nVERSION:3.0\r\nN:Doe;John\r\nFN:John Doe\r\nADR:;;Street;City;;123456;\r\nEND:VCARD\r\n' == vcard
    vcard = helpers.make_vcard_data('Doe;John', 'John Doe', street='123 Main Street', city='Any Town',
                                    region='CA', zipcode='91921-1234', country='Nummerland')
    assert 'BEGIN:VCARD\r\nVERSION:3.0\r\nN:Doe;John\r\nFN:John Doe\r\nADR:;;123 Main Street;Any Town;CA;91921-1234;Nummerland\r\nEND:VCARD\r\n' == vcard
    vcard = helpers.make_vcard_data('Doe;John', 'John Doe', title='Python wrangler')
    assert 'BEGIN:VCARD\r\nVERSION:3.0\r\nN:Doe;John\r\nFN:John Doe\r\nTITLE:Python wrangler\r\nEND:VCARD\r\n' == vcard
    vcard = helpers.make_vcard_data('Doe;John', 'John Doe',
                                    title=['Python wrangler', 'Snake charmer'])
    assert 'BEGIN:VCARD\r\nVERSION:3.0\r\nN:Doe;John\r\nFN:John Doe\r\nTITLE:Python wrangler\r\nTITLE:Snake charmer\r\nEND:VCARD\r\n' == vcard
    photo_uri = 'https://www.example.org/image.jpg'
    vcard = helpers.make_vcard_data('Doe;John', 'John Doe', photo_uri=photo_uri)
    assert 'BEGIN:VCARD\r\nVERSION:3.0\r\nN:Doe;John\r\nFN:John Doe\r\nPHOTO;VALUE=uri:{0}\r\nEND:VCARD\r\n'.format(photo_uri) == vcard
    photo_uris = ('https://www.example.org/image.jpg', 'https://www.example.com/image_another.gif')
    vcard = helpers.make_vcard_data('Doe;John', 'John Doe', photo_uri=photo_uris)
    assert 'BEGIN:VCARD\r\nVERSION:3.0\r\nN:Doe;John\r\nFN:John Doe\r\nPHOTO;VALUE=uri:{0}\r\nPHOTO;VALUE=uri:{1}\r\nEND:VCARD\r\n'.format(*photo_uris) == vcard
github heuer / segno / tests / test_helpers.py View on Github external
def test_vcard_data_invalid_geo():
    with pytest.raises(ValueError):
        helpers.make_vcard_data('Mustermann;Max', 'Max Mustermann', lat=1.234)
    with pytest.raises(ValueError):
        helpers.make_vcard_data('Mustermann;Max', 'Max Mustermann', lng=1.234)
github heuer / segno / tests / test_helpers.py View on Github external
def test_vcard_data_rev():
    expected_vcard_data = 'BEGIN:VCARD\r\nVERSION:3.0\r\nN:Mustermann;Max\r\nFN:Max Mustermann\r\nREV:1976-09-19\r\nEND:VCARD\r\n'
    vcard = helpers.make_vcard_data('Mustermann;Max', 'Max Mustermann', rev='1976-09-19')
    assert expected_vcard_data == vcard
    vcard = helpers.make_vcard_data('Mustermann;Max', 'Max Mustermann', rev=date(year=1976, month=9, day=19))
    assert expected_vcard_data == vcard