Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
matejmatuska committed Aug 22, 2022
1 parent f3b71a8 commit d18628c
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/scripts/test_workarounds_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
from multiprocessing import util, Process, Manager

import os
import pytest

import leapp # noqa: F401; pylint: disable=unused-import
from leapp.utils.workarounds import fqdn


def test_mp_is_patched():
Expand All @@ -29,3 +31,26 @@ def child_fun(_lst):
def test_mp_workaround_applied():
if getattr(util, 'os', None) is None:
assert util.Finalize.__name__ == 'FixedFinalize'


@pytest.mark.parametrize(
('input_fqdn', 'valid'),
[
('foo.bar.com', True),
('foo\xa0bar.foo.com', False),
('-foo.bar', False),
('foo.bar-', False),
('foo.-bar.1234', False),
('a1.b2.c3', True),
('123.foo.bar', True),
('123.f-o-o.b-a-r', True),
]
)
def test_fqdn_is_patched(input_fqdn, valid):

def getfqdn():
return input_fqdn

fn = fqdn.decorate_getfqdn(getfqdn)
expected_fqdn = input_fqdn if valid else 'invalid.hostname'
assert fn() == expected_fqdn

0 comments on commit d18628c

Please sign in to comment.