Skip to content

Commit

Permalink
tests: fix all flake8 issues
Browse files Browse the repository at this point in the history
Reviewed-by: Iker Pedrosa <[email protected]>
Reviewed-by: Jakub Vávra <[email protected]>
  • Loading branch information
pbrezina authored and alexey-tikhonov committed Feb 17, 2023
1 parent 59d2f94 commit f44e586
Show file tree
Hide file tree
Showing 17 changed files with 115 additions and 90 deletions.
2 changes: 1 addition & 1 deletion src/config/SSSDConfigTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
srcdir = srcdir + "/src/config"
else:
srcdir = "."
import SSSDConfig
import SSSDConfig # noqa


def create_temp_dir():
Expand Down
17 changes: 3 additions & 14 deletions src/sbus/codegen/sbus_CodeGen.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
import argparse
from collections import OrderedDict
from sbus_Introspection import Introspectable
from sbus_Template import *
from sbus_Generator import *
from sbus_Template import TemplateFile
from sbus_Generator import Generator
from sbus_DataType import DataType


class CodeGen:
Expand Down Expand Up @@ -78,18 +79,6 @@ def add(self, introspection_file):
def generate(self):
Generator.GenerateCode(self.templates, self.interfaces)

@staticmethod
def FilterAnnotations(annotations):
dict = OrderedDict()
if annotations is None or not annotations:
return dict

for name, annotation in annotations.items():
if not name.startswith("codegen."):
dict[name] = annotation

return dict

class Options:
def __init__(self,
SbusHeadersPath,
Expand Down
21 changes: 17 additions & 4 deletions src/sbus/codegen/sbus_Generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

from sbus_Invoker import *
from sbus_CodeGen import CodeGen
from collections import OrderedDict
from sbus_Invoker import Invoker, InvokerArgumentType, InvokerCaller, InvokerKeygen
from sbus_Introspection import SBus
from sbus_DataType import DataType


Expand Down Expand Up @@ -104,6 +105,18 @@ def __init__(self, interfaces, type):

templates.write()

@staticmethod
def FilterAnnotations(annotations):
dict = OrderedDict()
if annotations is None or not annotations:
return dict

for name, annotation in annotations.items():
if not name.startswith("codegen."):
dict[name] = annotation

return dict

class Base(object):
"""
Base object for code generators.
Expand Down Expand Up @@ -296,7 +309,7 @@ def toggleAnnotations(self, tpl, annotations):
"""

# We do not include codegen annotations.
filtered = CodeGen.FilterAnnotations(annotations)
filtered = Generator.FilterAnnotations(annotations)

show = True
if filtered is None or not filtered:
Expand Down Expand Up @@ -385,7 +398,7 @@ def argument(self, argument):

def generateAnnotations(self, token, annotations):
# We do not include codegen annotations.
filtered = CodeGen.FilterAnnotations(annotations)
filtered = Generator.FilterAnnotations(annotations)

if filtered is None or not filtered:
return
Expand Down
1 change: 1 addition & 0 deletions src/tests/intg/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from files_ops import passwd_ops_setup, group_ops_setup # noqa
2 changes: 1 addition & 1 deletion src/tests/intg/test_files_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import pytest

import ent
from files_ops import passwd_ops_setup, group_ops_setup


USER1 = dict(name='user1', passwd='*', uid=10001, gid=20001,
gecos='User for tests',
Expand Down
2 changes: 1 addition & 1 deletion src/tests/intg/test_files_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from sssd_passwd import (call_sssd_getpwnam,
call_sssd_getpwuid)
from sssd_group import call_sssd_getgrnam, call_sssd_getgrgid
from files_ops import passwd_ops_setup, group_ops_setup, PasswdOps, GroupOps
from files_ops import PasswdOps, GroupOps
from util import unindent

# Sync this with files_ops.c
Expand Down
1 change: 0 additions & 1 deletion src/tests/intg/test_kcm.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import krb5utils
import config
from util import unindent
from intg.files_ops import passwd_ops_setup

MAX_SECRETS = 10

Expand Down
1 change: 0 additions & 1 deletion src/tests/intg/test_pam_responder.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import pytest

from intg.util import unindent
from intg.files_ops import passwd_ops_setup

LDAP_BASE_DN = "dc=example,dc=com"

Expand Down
6 changes: 5 additions & 1 deletion src/tests/multihost/ad/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@
import pytest
import os
import posixpath
from sssd.testlib.common.qe_class import session_multihost
from sssd.testlib.common.paths import SSSD_DEFAULT_CONF
from sssd.testlib.common.exceptions import SSSDException
from sssd.testlib.common.utils import ADOperations
from sssd.testlib.common.samba import sambaTools
from sssd.testlib.common.utils import sssdTools


pytest_plugins = (
'sssd.testlib.common.fixtures',
)


def pytest_configure():
""" Namespace hook, Adds below dict to pytest namespace """
pytest.num_masters = 1
Expand Down
6 changes: 5 additions & 1 deletion src/tests/multihost/admultidomain/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@
import subprocess
import random
import pytest
from sssd.testlib.common.qe_class import session_multihost
from sssd.testlib.common.paths import SSSD_DEFAULT_CONF
from sssd.testlib.common.utils import sssdTools


pytest_plugins = (
'sssd.testlib.common.fixtures',
)


def pytest_configure():
""" Namespace hook, Adds below dict to pytest namespace """
pytest.num_masters = 0
Expand Down
6 changes: 5 additions & 1 deletion src/tests/multihost/adsites/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@
import pytest
import os
import posixpath
from sssd.testlib.common.qe_class import session_multihost
from sssd.testlib.common.paths import SSSD_DEFAULT_CONF
from sssd.testlib.common.exceptions import SSSDException
from sssd.testlib.common.samba import sambaTools
from sssd.testlib.common.utils import sssdTools


pytest_plugins = (
'sssd.testlib.common.fixtures',
)


def pytest_configure():
""" Namespace hook, Adds below dict to pytest namespace """
pytest.num_masters = 0
Expand Down
6 changes: 5 additions & 1 deletion src/tests/multihost/alltests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,17 @@
from constants import ds_instance_name, ds_suffix, krb_realm, ds_rootdn, ds_rootpw
from sssd.testlib.common.libkrb5 import krb5srv
from sssd.testlib.common.paths import SSSD_DEFAULT_CONF, NSSWITCH_DEFAULT_CONF
from sssd.testlib.common.qe_class import session_multihost
from sssd.testlib.common.utils import PkiTools, sssdTools, LdapOperations
from sssd.testlib.common.libdirsrv import DirSrvWrap
from sssd.testlib.common.exceptions import PkiLibException, LdapException
from datetime import datetime, timedelta


pytest_plugins = (
'sssd.testlib.common.fixtures',
)


def pytest_configure():
""" Namespace hook to add below dict in the pytest namespace """
pytest.num_masters = 2
Expand Down
9 changes: 5 additions & 4 deletions src/tests/multihost/basic/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from sssd.testlib.common.qe_class import session_multihost
from sssd.testlib.common.libkrb5 import krb5srv
from sssd.testlib.common.utils import sssdTools, PkiTools
from sssd.testlib.common.utils import LdapOperations
Expand All @@ -16,6 +15,11 @@
import ldap


pytest_plugins = (
'sssd.testlib.common.fixtures',
)


def pytest_configure():
pytest.num_masters = 1
pytest.num_ad = 0
Expand Down Expand Up @@ -449,9 +453,6 @@ def setup_session(request, session_multihost,
create_posix_usersgroups,
enable_oddjob):
""" Run all session scoped fixtures """
# pylint: disable=unused-argument
_pytest_fixture = [package_install, run_authselect,
setup_ldap, setup_kerberos, create_posix_usersgroups]
tp = TestPrep(session_multihost)
tp.setup()

Expand Down
2 changes: 1 addition & 1 deletion src/tests/multihost/basic/mhc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ domains:
type: sssd
hosts:
- name: client
external_hostname: master.client.vm
external_hostname: client.test
role: master
6 changes: 5 additions & 1 deletion src/tests/multihost/ipa/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,17 @@
import posixpath
import pexpect
import pytest
from sssd.testlib.common.qe_class import session_multihost
from sssd.testlib.common.utils import sssdTools
from sssd.testlib.ipa.utils import ipaTools
from sssd.testlib.common.utils import ADOperations
from sssd.testlib.common.paths import SSSD_DEFAULT_CONF


pytest_plugins = (
'sssd.testlib.common.fixtures',
)


def pytest_configure():
""" Namespace hook to add below dict in the pytest namespace """
pytest.num_masters = 1
Expand Down
60 changes: 60 additions & 0 deletions src/tests/multihost/sssd/testlib/common/fixtures.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import pytest
from pytest_multihost import make_multihost_fixture

from .qe_class import QeConfig


@pytest.fixture(scope="session", autouse=True)
def session_multihost(request):
# pylint: disable=no-member
"""Multihost plugin fixture for session scope"""
if pytest.num_ad > 0:
mhost = make_multihost_fixture(request, descriptions=[
{
'type': 'sssd',
'hosts':
{
'master': pytest.num_masters,
'atomic': pytest.num_atomic,
'replica': pytest.num_replicas,
'client': pytest.num_clients,
'other': pytest.num_others,
}
},
{
'type': 'ad',
'hosts':
{
'ad': pytest.num_ad,
},
},
], config_class=QeConfig,)
else:
mhost = make_multihost_fixture(request, descriptions=[
{
'type': 'sssd',
'hosts':
{
'master': pytest.num_masters,
'atomic': pytest.num_atomic,
'replica': pytest.num_replicas,
'client': pytest.num_clients,
'other': pytest.num_others,
}
},
], config_class=QeConfig,)
mhost.domain = mhost.config.domains[0]
mhost.master = mhost.domain.hosts_by_role('master')
mhost.atomic = mhost.domain.hosts_by_role('atomic')
mhost.replica = mhost.domain.hosts_by_role('replica')
mhost.client = mhost.domain.hosts_by_role('client')
mhost.others = mhost.domain.hosts_by_role('other')

if pytest.num_ad > 0:
mhost.ad = []
for i in range(1, pytest.num_ad + 1):
print(i)
print(mhost.config.domains[i].hosts_by_role('ad'))
mhost.ad.extend(mhost.config.domains[i].hosts_by_role('ad'))

yield mhost
57 changes: 0 additions & 57 deletions src/tests/multihost/sssd/testlib/common/qe_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import time
import logging
import pytest
from pytest_multihost import make_multihost_fixture
import pytest_multihost.config
import pytest_multihost.host
from .exceptions import SSSDException
Expand Down Expand Up @@ -296,62 +295,6 @@ def __init__(self, config, name, domain_type):
host_classes = {'default': QeHost, 'windows': QeWinHost}


@pytest.fixture(scope="session", autouse=True)
def session_multihost(request):
# pylint: disable=no-member
"""Multihost plugin fixture for session scope"""
if pytest.num_ad > 0:
mhost = make_multihost_fixture(request, descriptions=[
{
'type': 'sssd',
'hosts':
{
'master': pytest.num_masters,
'atomic': pytest.num_atomic,
'replica': pytest.num_replicas,
'client': pytest.num_clients,
'other': pytest.num_others,
}
},
{
'type': 'ad',
'hosts':
{
'ad': pytest.num_ad,
},
},
], config_class=QeConfig,)
else:
mhost = make_multihost_fixture(request, descriptions=[
{
'type': 'sssd',
'hosts':
{
'master': pytest.num_masters,
'atomic': pytest.num_atomic,
'replica': pytest.num_replicas,
'client': pytest.num_clients,
'other': pytest.num_others,
}
},
], config_class=QeConfig,)
mhost.domain = mhost.config.domains[0]
mhost.master = mhost.domain.hosts_by_role('master')
mhost.atomic = mhost.domain.hosts_by_role('atomic')
mhost.replica = mhost.domain.hosts_by_role('replica')
mhost.client = mhost.domain.hosts_by_role('client')
mhost.others = mhost.domain.hosts_by_role('other')

if pytest.num_ad > 0:
mhost.ad = []
for i in range(1, pytest.num_ad + 1):
print(i)
print(mhost.config.domains[i].hosts_by_role('ad'))
mhost.ad.extend(mhost.config.domains[i].hosts_by_role('ad'))

yield mhost


# pylint: disable=redefined-outer-name
@pytest.fixture(scope='session', autouse=True)
def create_testdir(session_multihost, request):
Expand Down

0 comments on commit f44e586

Please sign in to comment.