Imported Upstream version 4.6.2
This commit is contained in:
0
ipatests/test_ipaplatform/__init__.py
Normal file
0
ipatests/test_ipaplatform/__init__.py
Normal file
15
ipatests/test_ipaplatform/data/os-release-centos
Normal file
15
ipatests/test_ipaplatform/data/os-release-centos
Normal file
@@ -0,0 +1,15 @@
|
||||
NAME="CentOS Linux"
|
||||
VERSION="7 (Core)"
|
||||
ID="centos"
|
||||
ID_LIKE="rhel fedora"
|
||||
VERSION_ID="7"
|
||||
PRETTY_NAME="CentOS Linux 7 (Core)"
|
||||
ANSI_COLOR="0;31"
|
||||
CPE_NAME="cpe:/o:centos:centos:7"
|
||||
HOME_URL="https://www.centos.org/"
|
||||
BUG_REPORT_URL="https://bugs.centos.org/"
|
||||
|
||||
CENTOS_MANTISBT_PROJECT="CentOS-7"
|
||||
CENTOS_MANTISBT_PROJECT_VERSION="7"
|
||||
REDHAT_SUPPORT_PRODUCT="centos"
|
||||
REDHAT_SUPPORT_PRODUCT_VERSION="7"
|
||||
16
ipatests/test_ipaplatform/data/os-release-fedora
Normal file
16
ipatests/test_ipaplatform/data/os-release-fedora
Normal file
@@ -0,0 +1,16 @@
|
||||
NAME=Fedora
|
||||
VERSION="26 (Workstation Edition)"
|
||||
ID=fedora
|
||||
VERSION_ID=26
|
||||
PRETTY_NAME="Fedora 26 (Workstation Edition)"
|
||||
ANSI_COLOR="0;34"
|
||||
CPE_NAME="cpe:/o:fedoraproject:fedora:26"
|
||||
HOME_URL="https://fedoraproject.org/"
|
||||
BUG_REPORT_URL="https://bugzilla.redhat.com/"
|
||||
REDHAT_BUGZILLA_PRODUCT="Fedora"
|
||||
REDHAT_BUGZILLA_PRODUCT_VERSION=26
|
||||
REDHAT_SUPPORT_PRODUCT="Fedora"
|
||||
REDHAT_SUPPORT_PRODUCT_VERSION=26
|
||||
PRIVACY_POLICY_URL=https://fedoraproject.org/wiki/Legal:PrivacyPolicy
|
||||
VARIANT="Workstation Edition"
|
||||
VARIANT_ID=workstation
|
||||
11
ipatests/test_ipaplatform/data/os-release-ubuntu
Normal file
11
ipatests/test_ipaplatform/data/os-release-ubuntu
Normal file
@@ -0,0 +1,11 @@
|
||||
NAME="Ubuntu"
|
||||
VERSION="16.04.3 LTS (Xenial Xerus)"
|
||||
ID=ubuntu
|
||||
ID_LIKE=debian
|
||||
PRETTY_NAME="Ubuntu 16.04.3 LTS"
|
||||
VERSION_ID="16.04"
|
||||
HOME_URL="http://www.ubuntu.com/"
|
||||
SUPPORT_URL="http://help.ubuntu.com/"
|
||||
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
|
||||
VERSION_CODENAME=xenial
|
||||
UBUNTU_CODENAME=xenial
|
||||
54
ipatests/test_ipaplatform/test_importhook.py
Normal file
54
ipatests/test_ipaplatform/test_importhook.py
Normal file
@@ -0,0 +1,54 @@
|
||||
#
|
||||
# Copyright (C) 2017 FreeIPA Contributors see COPYING for license
|
||||
#
|
||||
import os
|
||||
import sys
|
||||
|
||||
import pytest
|
||||
|
||||
import ipaplatform.constants
|
||||
import ipaplatform.paths
|
||||
import ipaplatform.services
|
||||
import ipaplatform.tasks
|
||||
from ipaplatform._importhook import metaimporter
|
||||
try:
|
||||
from ipaplatform.override import OVERRIDE
|
||||
except ImportError:
|
||||
OVERRIDE = None
|
||||
|
||||
|
||||
HERE = os.path.dirname(os.path.abspath(__file__))
|
||||
DATA = os.path.join(HERE, 'data')
|
||||
|
||||
|
||||
@pytest.mark.skipif(OVERRIDE is None,
|
||||
reason='test requires override')
|
||||
def test_override():
|
||||
assert OVERRIDE == metaimporter.platform_ids[0]
|
||||
assert OVERRIDE == metaimporter.platform
|
||||
|
||||
|
||||
@pytest.mark.parametrize('mod, name', [
|
||||
(ipaplatform.constants, 'ipaplatform.constants'),
|
||||
(ipaplatform.paths, 'ipaplatform.paths'),
|
||||
(ipaplatform.services, 'ipaplatform.services'),
|
||||
(ipaplatform.tasks, 'ipaplatform.tasks'),
|
||||
])
|
||||
def test_importhook(mod, name):
|
||||
assert name in metaimporter.modules
|
||||
prefix, suffix = name.split('.')
|
||||
assert prefix == 'ipaplatform'
|
||||
override = '.'.join((prefix, metaimporter.platform, suffix))
|
||||
assert mod.__name__ == override
|
||||
# dicts are equal, modules may not be identical
|
||||
assert mod.__dict__ == sys.modules[override].__dict__
|
||||
|
||||
|
||||
@pytest.mark.parametrize('filename, expected_platforms', [
|
||||
(os.path.join(DATA, 'os-release-centos'), ['centos', 'rhel', 'fedora']),
|
||||
(os.path.join(DATA, 'os-release-fedora'), ['fedora']),
|
||||
(os.path.join(DATA, 'os-release-ubuntu'), ['ubuntu', 'debian']),
|
||||
])
|
||||
def test_parse_os_release(filename, expected_platforms):
|
||||
parsed = metaimporter._parse_osrelease(filename)
|
||||
assert parsed == expected_platforms
|
||||
Reference in New Issue
Block a user