generate vCard in utils.py; added Tests
This commit is contained in:
29
tests/test_utils_vcard.py
Normal file
29
tests/test_utils_vcard.py
Normal file
@@ -0,0 +1,29 @@
|
||||
from types import SimpleNamespace
|
||||
from pathlib import Path
|
||||
|
||||
from utils import generate_vcard
|
||||
|
||||
|
||||
def test_generate_vcard_writes_file(tmp_path):
|
||||
addr = SimpleNamespace(
|
||||
vorname='Anna',
|
||||
nachname='Muster',
|
||||
strasse='Beispielweg',
|
||||
hausnummer='5a',
|
||||
plz='54321',
|
||||
ort='Beispielstadt',
|
||||
land='Deutschland',
|
||||
email='anna@example.com',
|
||||
telefon_vorwahl='49',
|
||||
telefon_nummer='7654321',
|
||||
id=42,
|
||||
)
|
||||
|
||||
path = generate_vcard(addr, str(tmp_path))
|
||||
assert Path(path).exists()
|
||||
|
||||
content = Path(path).read_text(encoding='utf-8')
|
||||
assert 'BEGIN:VCARD' in content
|
||||
assert 'FN:Anna Muster' in content
|
||||
assert 'EMAIL;TYPE=internet:anna@example.com' in content
|
||||
assert 'TEL;TYPE=voice:+497654321' in content
|
||||
Reference in New Issue
Block a user