make identation a bit more readable

This commit is contained in:
2022-04-17 17:27:38 +03:00
parent 3016a919c5
commit 60bb880f9f
167 changed files with 1533 additions and 1538 deletions

View File

@ -15,12 +15,12 @@ def application_packages(configuration: Configuration, database: SQLite, mocker:
fixture for application with package functions
Args:
configuration(Configuration): configuration fixture
database(SQLite): database fixture
mocker(MockerFixture): mocker object
configuration(Configuration): configuration fixture
database(SQLite): database fixture
mocker(MockerFixture): mocker object
Returns:
Packages: application test instance
Packages: application test instance
"""
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
mocker.patch("ahriman.core.database.sqlite.SQLite.load", return_value=database)
@ -33,12 +33,12 @@ def application_properties(configuration: Configuration, database: SQLite, mocke
fixture for application with properties only
Args:
configuration(Configuration): configuration fixture
database(SQLite): database fixture
mocker(MockerFixture): mocker object
configuration(Configuration): configuration fixture
database(SQLite): database fixture
mocker(MockerFixture): mocker object
Returns:
Properties: application test instance
Properties: application test instance
"""
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
mocker.patch("ahriman.core.database.sqlite.SQLite.load", return_value=database)
@ -51,12 +51,12 @@ def application_repository(configuration: Configuration, database: SQLite, mocke
fixture for application with repository functions
Args:
configuration(Configuration): configuration fixture
database(SQLite): database fixture
mocker(MockerFixture): mocker object
configuration(Configuration): configuration fixture
database(SQLite): database fixture
mocker(MockerFixture): mocker object
Returns:
Repository: application test instance
Repository: application test instance
"""
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
mocker.patch("ahriman.core.database.sqlite.SQLite.load", return_value=database)

View File

@ -16,12 +16,12 @@ def application(configuration: Configuration, database: SQLite, mocker: MockerFi
fixture for application
Args:
configuration(Configuration): configuration fixture
database(SQLite): database fixture
mocker(MockerFixture): mocker object
configuration(Configuration): configuration fixture
database(SQLite): database fixture
mocker(MockerFixture): mocker object
Returns:
Application: application test instance
Application: application test instance
"""
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
mocker.patch("ahriman.core.database.sqlite.SQLite.load", return_value=database)
@ -34,7 +34,7 @@ def args() -> argparse.Namespace:
fixture for command line arguments
Returns:
argparse.Namespace: command line arguments test instance
argparse.Namespace: command line arguments test instance
"""
return argparse.Namespace(architecture=None, lock=None, force=False, unsafe=False, no_report=True)
@ -45,8 +45,8 @@ def lock(args: argparse.Namespace, configuration: Configuration) -> Lock:
fixture for file lock
Args:
args(argparse.Namespace): command line arguments fixture
configuration(Configuration): configuration fixture
args(argparse.Namespace): command line arguments fixture
configuration(Configuration): configuration fixture
Returns:
Lock: file lock test instance
@ -60,6 +60,6 @@ def parser() -> argparse.ArgumentParser:
fixture for command line arguments parser
Returns:
argparse.ArgumentParser: command line arguments parser test instance
argparse.ArgumentParser: command line arguments parser test instance
"""
return _parser()

View File

@ -15,10 +15,10 @@ def _default_args(args: argparse.Namespace) -> argparse.Namespace:
default arguments for these test cases
Args:
args(argparse.Namespace): command line arguments fixture
args(argparse.Namespace): command line arguments fixture
Returns:
argparse.Namespace: generated arguments for these test cases
argparse.Namespace: generated arguments for these test cases
"""
args.package = []
args.exit_code = False

View File

@ -14,10 +14,10 @@ def _default_args(args: argparse.Namespace) -> argparse.Namespace:
default arguments for these test cases
Args:
args(argparse.Namespace): command line arguments fixture
args(argparse.Namespace): command line arguments fixture
Returns:
argparse.Namespace: generated arguments for these test cases
argparse.Namespace: generated arguments for these test cases
"""
args.path = Path("result.tar.gz")
return args

View File

@ -11,10 +11,10 @@ def _default_args(args: argparse.Namespace) -> argparse.Namespace:
default arguments for these test cases
Args:
args(argparse.Namespace): command line arguments fixture
args(argparse.Namespace): command line arguments fixture
Returns:
argparse.Namespace: generated arguments for these test cases
argparse.Namespace: generated arguments for these test cases
"""
args.cache = False
args.chroot = False

View File

@ -12,10 +12,10 @@ def _default_args(args: argparse.Namespace) -> argparse.Namespace:
default arguments for these test cases
Args:
args(argparse.Namespace): command line arguments fixture
args(argparse.Namespace): command line arguments fixture
Returns:
argparse.Namespace: generated arguments for these test cases
argparse.Namespace: generated arguments for these test cases
"""
args.parser = _parser
args.command = None

View File

@ -11,10 +11,10 @@ def _default_args(args: argparse.Namespace) -> argparse.Namespace:
default arguments for these test cases
Args:
args(argparse.Namespace): command line arguments fixture
args(argparse.Namespace): command line arguments fixture
Returns:
argparse.Namespace: generated arguments for these test cases
argparse.Namespace: generated arguments for these test cases
"""
args.key = "0xE989490C"
args.key_server = "pgp.mit.edu"

View File

@ -15,10 +15,10 @@ def _default_args(args: argparse.Namespace) -> argparse.Namespace:
default arguments for these test cases
Args:
args(argparse.Namespace): command line arguments fixture
args(argparse.Namespace): command line arguments fixture
Returns:
argparse.Namespace: generated arguments for these test cases
argparse.Namespace: generated arguments for these test cases
"""
args.package = "ahriman"
args.exit_code = False

View File

@ -16,10 +16,10 @@ def _default_args(args: argparse.Namespace) -> argparse.Namespace:
default arguments for these test cases
Args:
args(argparse.Namespace): command line arguments fixture
args(argparse.Namespace): command line arguments fixture
Returns:
argparse.Namespace: generated arguments for these test cases
argparse.Namespace: generated arguments for these test cases
"""
args.depends_on = []
args.dry_run = False

View File

@ -11,10 +11,10 @@ def _default_args(args: argparse.Namespace) -> argparse.Namespace:
default arguments for these test cases
Args:
args(argparse.Namespace): command line arguments fixture
args(argparse.Namespace): command line arguments fixture
Returns:
argparse.Namespace: generated arguments for these test cases
argparse.Namespace: generated arguments for these test cases
"""
args.package = []
return args

View File

@ -12,10 +12,10 @@ def _default_args(args: argparse.Namespace) -> argparse.Namespace:
default arguments for these test cases
Args:
args(argparse.Namespace): command line arguments fixture
args(argparse.Namespace): command line arguments fixture
Returns:
argparse.Namespace: generated arguments for these test cases
argparse.Namespace: generated arguments for these test cases
"""
args.dry_run = False
args.info = False

View File

@ -12,10 +12,10 @@ def _default_args(args: argparse.Namespace) -> argparse.Namespace:
default arguments for these test cases
Args:
args(argparse.Namespace): command line arguments fixture
args(argparse.Namespace): command line arguments fixture
Returns:
argparse.Namespace: generated arguments for these test cases
argparse.Namespace: generated arguments for these test cases
"""
args.target = []
return args

View File

@ -13,10 +13,10 @@ def _default_args(args: argparse.Namespace) -> argparse.Namespace:
default arguments for these test cases
Args:
args(argparse.Namespace): command line arguments fixture
args(argparse.Namespace): command line arguments fixture
Returns:
argparse.Namespace: generated arguments for these test cases
argparse.Namespace: generated arguments for these test cases
"""
args.path = Path("result.tar.gz")
args.output = Path.cwd()

View File

@ -16,10 +16,10 @@ def _default_args(args: argparse.Namespace) -> argparse.Namespace:
default arguments for these test cases
Args:
args(argparse.Namespace): command line arguments fixture
args(argparse.Namespace): command line arguments fixture
Returns:
argparse.Namespace: generated arguments for these test cases
argparse.Namespace: generated arguments for these test cases
"""
args.search = ["ahriman"]
args.exit_code = False

View File

@ -16,10 +16,10 @@ def _default_args(args: argparse.Namespace) -> argparse.Namespace:
default arguments for these test cases
Args:
args(argparse.Namespace): command line arguments fixture
args(argparse.Namespace): command line arguments fixture
Returns:
argparse.Namespace: generated arguments for these test cases
argparse.Namespace: generated arguments for these test cases
"""
args.build_as_user = "ahriman"
args.build_command = "ahriman"

View File

@ -11,10 +11,10 @@ def _default_args(args: argparse.Namespace) -> argparse.Namespace:
default arguments for these test cases
Args:
args(argparse.Namespace): command line arguments fixture
args(argparse.Namespace): command line arguments fixture
Returns:
argparse.Namespace: generated arguments for these test cases
argparse.Namespace: generated arguments for these test cases
"""
args.package = []
return args

View File

@ -14,10 +14,10 @@ def _default_args(args: argparse.Namespace) -> argparse.Namespace:
default arguments for these test cases
Args:
args(argparse.Namespace): command line arguments fixture
args(argparse.Namespace): command line arguments fixture
Returns:
argparse.Namespace: generated arguments for these test cases
argparse.Namespace: generated arguments for these test cases
"""
args.ahriman = True
args.exit_code = False

View File

@ -14,10 +14,10 @@ def _default_args(args: argparse.Namespace) -> argparse.Namespace:
default arguments for these test cases
Args:
args(argparse.Namespace): command line arguments fixture
args(argparse.Namespace): command line arguments fixture
Returns:
argparse.Namespace: generated arguments for these test cases
argparse.Namespace: generated arguments for these test cases
"""
args.package = None
args.action = Action.Update

View File

@ -11,10 +11,10 @@ def _default_args(args: argparse.Namespace) -> argparse.Namespace:
default arguments for these test cases
Args:
args(argparse.Namespace): command line arguments fixture
args(argparse.Namespace): command line arguments fixture
Returns:
argparse.Namespace: generated arguments for these test cases
argparse.Namespace: generated arguments for these test cases
"""
args.target = []
return args

View File

@ -13,10 +13,10 @@ def _default_args(args: argparse.Namespace) -> argparse.Namespace:
default arguments for these test cases
Args:
args(argparse.Namespace): command line arguments fixture
args(argparse.Namespace): command line arguments fixture
Returns:
argparse.Namespace: generated arguments for these test cases
argparse.Namespace: generated arguments for these test cases
"""
args.parser = _parser
args.command = None

View File

@ -16,10 +16,10 @@ def _default_args(args: argparse.Namespace) -> argparse.Namespace:
default arguments for these test cases
Args:
args(argparse.Namespace): command line arguments fixture
args(argparse.Namespace): command line arguments fixture
Returns:
argparse.Namespace: generated arguments for these test cases
argparse.Namespace: generated arguments for these test cases
"""
args.package = []
args.dry_run = False

View File

@ -18,10 +18,10 @@ def _default_args(args: argparse.Namespace) -> argparse.Namespace:
default arguments for these test cases
Args:
args(argparse.Namespace): command line arguments fixture
args(argparse.Namespace): command line arguments fixture
Returns:
argparse.Namespace: generated arguments for these test cases
argparse.Namespace: generated arguments for these test cases
"""
args.username = "user"
args.action = Action.Update

View File

@ -12,10 +12,10 @@ def _default_args(args: argparse.Namespace) -> argparse.Namespace:
default arguments for these test cases
Args:
args(argparse.Namespace): command line arguments fixture
args(argparse.Namespace): command line arguments fixture
Returns:
argparse.Namespace: generated arguments for these test cases
argparse.Namespace: generated arguments for these test cases
"""
args.parser = lambda: True
return args

View File

@ -32,10 +32,10 @@ def anyvar(cls: Type[T], strict: bool = False) -> T:
any value helper for mocker calls check
Args:
strict(bool, optional): if True then check type of supplied argument (Default value = False)
strict(bool, optional): if True then check type of supplied argument (Default value = False)
Returns:
T: any wrapper
T: any wrapper
"""
class AnyVar(cls):
"""any value wrapper"""
@ -45,10 +45,10 @@ def anyvar(cls: Type[T], strict: bool = False) -> T:
compare object to other
Args:
other(Any): other object to compare
other(Any): other object to compare
Returns:
bool: True in case if objects are equal
bool: True in case if objects are equal
"""
return not strict or isinstance(other, cls)
@ -61,10 +61,10 @@ def get_package_status(package: Package) -> Dict[str, Any]:
helper to extract package status from package
Args:
package(Package): package object
package(Package): package object
Returns:
Dict[str, Any]: simplified package status map (with only status and view)
Dict[str, Any]: simplified package status map (with only status and view)
"""
return {"status": BuildStatusEnum.Unknown.value, "package": package.view()}
@ -75,10 +75,10 @@ def get_package_status_extended(package: Package) -> Dict[str, Any]:
helper to extract package status from package
Args:
package(Package): package object
package(Package): package object
Returns:
Dict[str, Any]: full package status map (with timestamped build status and view)
Dict[str, Any]: full package status map (with timestamped build status and view)
"""
return {"status": BuildStatus().view(), "package": package.view()}
@ -90,7 +90,7 @@ def aur_package_ahriman() -> AURPackage:
fixture for AUR package
Returns:
AURPackage: AUR package test instance
AURPackage: AUR package test instance
"""
return AURPackage(
id=1009791,
@ -145,7 +145,7 @@ def aur_package_akonadi() -> AURPackage:
fixture for AUR package
Returns:
AURPackage: AUR package test instance
AURPackage: AUR package test instance
"""
return AURPackage(
id=0,
@ -191,10 +191,10 @@ def auth(configuration: Configuration) -> Auth:
auth provider fixture
Args:
configuration(Configuration): configuration fixture
configuration(Configuration): configuration fixture
Returns:
Auth: auth service instance
Auth: auth service instance
"""
return Auth(configuration)
@ -205,10 +205,10 @@ def configuration(resource_path_root: Path) -> Configuration:
configuration fixture
Args:
resource_path_root(Path): resource path root directory
resource_path_root(Path): resource path root directory
Returns:
Configuration: configuration test instance
Configuration: configuration test instance
"""
path = resource_path_root / "core" / "ahriman.ini"
return Configuration.from_path(path=path, architecture="x86_64", quiet=False)
@ -220,10 +220,10 @@ def database(configuration: Configuration) -> SQLite:
database fixture
Args:
configuration(Configuration): configuration fixture
configuration(Configuration): configuration fixture
Returns:
SQLite: database test instance
SQLite: database test instance
"""
database = SQLite.load(configuration)
yield database
@ -236,10 +236,10 @@ def package_ahriman(package_description_ahriman: PackageDescription) -> Package:
package fixture
Args:
package_description_ahriman(PackageDescription): description fixture
package_description_ahriman(PackageDescription): description fixture
Returns:
Package: package test instance
Package: package test instance
"""
packages = {"ahriman": package_description_ahriman}
return Package(
@ -257,11 +257,11 @@ def package_python_schedule(
multi package fixture
Args:
package_description_python_schedule(PackageDescription): description fixture
package_description_python2_schedule(PackageDescription): description fixture
package_description_python_schedule(PackageDescription): description fixture
package_description_python2_schedule(PackageDescription): description fixture
Returns:
Package: multi package test instance
Package: multi package test instance
"""
packages = {
"python-schedule": package_description_python_schedule,
@ -280,7 +280,7 @@ def package_description_ahriman() -> PackageDescription:
package description fixture
Returns:
PackageDescription: package description test instance
PackageDescription: package description test instance
"""
return PackageDescription(
architecture="x86_64",
@ -308,7 +308,7 @@ def package_description_python_schedule() -> PackageDescription:
package description fixture
Returns:
PackageDescription: package description test instance
PackageDescription: package description test instance
"""
return PackageDescription(
architecture="x86_64",
@ -329,7 +329,7 @@ def package_description_python2_schedule() -> PackageDescription:
package description fixture
Returns:
PackageDescription: package description test instance
PackageDescription: package description test instance
"""
return PackageDescription(
architecture="x86_64",
@ -350,10 +350,10 @@ def repository_paths(configuration: Configuration) -> RepositoryPaths:
repository paths fixture
Args:
configuration(Configuration): configuration fixture
configuration(Configuration): configuration fixture
Returns:
RepositoryPaths: repository paths test instance
RepositoryPaths: repository paths test instance
"""
return configuration.repository_paths
@ -364,10 +364,10 @@ def result(package_ahriman: Package) -> Result:
result fixture
Args:
package_ahriman(Package): package fixture
package_ahriman(Package): package fixture
Returns:
Result: result test instance
Result: result test instance
"""
result = Result()
result.add_success(package_ahriman)
@ -380,10 +380,10 @@ def spawner(configuration: Configuration) -> Spawn:
spawner fixture
Args:
configuration(Configuration): configuration fixture
configuration(Configuration): configuration fixture
Returns:
Spawn: spawner fixture
Spawn: spawner fixture
"""
return Spawn(MagicMock(), "x86_64", configuration)
@ -394,7 +394,7 @@ def user() -> User:
fixture for user descriptor
Returns:
User: user descriptor instance
User: user descriptor instance
"""
return User("user", "pa55w0rd", UserAccess.Read)
@ -405,12 +405,12 @@ def watcher(configuration: Configuration, database: SQLite, mocker: MockerFixtur
package status watcher fixture
Args:
configuration(Configuration): configuration fixture
database(SQLite): database fixture
mocker(MockerFixture): mocker object
configuration(Configuration): configuration fixture
database(SQLite): database fixture
mocker(MockerFixture): mocker object
Returns:
Watcher: package status watcher test instance
Watcher: package status watcher test instance
"""
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
return Watcher("x86_64", configuration, database)

View File

@ -11,7 +11,7 @@ def aur() -> AUR:
aur helper fixture
Returns:
AUR: aur helper instance
AUR: aur helper instance
"""
return AUR()
@ -22,7 +22,7 @@ def official() -> Official:
official repository fixture
Returns:
Official: official repository helper instance
Official: official repository helper instance
"""
return Official()
@ -33,6 +33,6 @@ def remote() -> Remote:
official repository fixture
Returns:
Remote: official repository helper instance
Remote: official repository helper instance
"""
return Remote()

View File

@ -16,10 +16,10 @@ def _get_response(resource_path_root: Path) -> str:
load response from resource file
Args:
resource_path_root(Path): path to resource root
resource_path_root(Path): path to resource root
Returns:
str: response text
str: response text
"""
return (resource_path_root / "models" / "package_ahriman_aur").read_text()

View File

@ -16,10 +16,10 @@ def _get_response(resource_path_root: Path) -> str:
load response from resource file
Args:
resource_path_root(Path): path to resource root
resource_path_root(Path): path to resource root
Returns:
str: response text
str: response text
"""
return (resource_path_root / "models" / "package_akonadi_aur").read_text()

View File

@ -12,14 +12,11 @@ def mapping(configuration: Configuration, database: SQLite) -> Mapping:
auth provider fixture
Args:
configuration(Configuration): configuration fixture
database(SQLite): database fixture
configuration(Configuration): configuration fixture
database(SQLite): database fixture
Returns:
Mapping: auth service instance
Raises:
Mapping: auth service instance
"""
return Mapping(configuration, database)
@ -30,14 +27,11 @@ def oauth(configuration: Configuration, database: SQLite) -> OAuth:
OAuth provider fixture
Args:
configuration(Configuration): configuration fixture
database(SQLite): database fixture
configuration(Configuration): configuration fixture
database(SQLite): database fixture
Returns:
OAuth: OAuth2 service instance
Raises:
OAuth: OAuth2 service instance
"""
configuration.set("web", "address", "https://example.com")
return OAuth(configuration, database)

View File

@ -15,10 +15,10 @@ def leaf_ahriman(package_ahriman: Package) -> Leaf:
fixture for tree leaf with package
Args:
package_ahriman(Package): package fixture
package_ahriman(Package): package fixture
Returns:
Leaf: tree leaf test instance
Leaf: tree leaf test instance
"""
return Leaf(package_ahriman, set())
@ -29,10 +29,10 @@ def leaf_python_schedule(package_python_schedule: Package) -> Leaf:
fixture for tree leaf with package
Args:
package_python_schedule(Package): package fixture
package_python_schedule(Package): package fixture
Returns:
Leaf: tree leaf test instance
Leaf: tree leaf test instance
"""
return Leaf(package_python_schedule, set())
@ -43,10 +43,10 @@ def pacman(configuration: Configuration) -> Pacman:
fixture for pacman wrapper
Args:
configuration(Configuration): configuration fixture
configuration(Configuration): configuration fixture
Returns:
Pacman: pacman wrapper test instance
Pacman: pacman wrapper test instance
"""
return Pacman(configuration)
@ -57,11 +57,11 @@ def repo(configuration: Configuration, repository_paths: RepositoryPaths) -> Rep
fixture for repository wrapper
Args:
configuration(Configuration): configuration fixture
repository_paths(RepositoryPaths): repository paths fixture
configuration(Configuration): configuration fixture
repository_paths(RepositoryPaths): repository paths fixture
Returns:
Repo: repository wrapper test instance
Repo: repository wrapper test instance
"""
return Repo(configuration.get("repository", "name"), repository_paths, [])
@ -72,9 +72,9 @@ def task_ahriman(package_ahriman: Package, configuration: Configuration, reposit
fixture for built task
Args:
package_ahriman(Package): package fixture
configuration(Configuration): configuration fixture
repository_paths(RepositoryPaths): repository paths fixture
package_ahriman(Package): package fixture
configuration(Configuration): configuration fixture
repository_paths(RepositoryPaths): repository paths fixture
Returns:
Task: built task test instance

View File

@ -10,6 +10,6 @@ def connection() -> Connection:
mock object for sqlite3 connection
Returns:
Connection: sqlite3 connection test instance
Connection: sqlite3 connection test instance
"""
return MagicMock()

View File

@ -11,9 +11,9 @@ def migrations(connection: Connection) -> Migrations:
fixture for migrations object
Args:
connection(Connection): sqlite connection fixture
connection(Connection): sqlite connection fixture
Returns:
Migrations: migrations test instance
Migrations: migrations test instance
"""
return Migrations(connection)

View File

@ -22,7 +22,7 @@ def aur_package_ahriman_printer(aur_package_ahriman: AURPackage) -> AurPrinter:
aur_package_ahriman(AURPackage): AUR package fixture
Returns:
AurPrinter: AUR package printer test instance
AurPrinter: AUR package printer test instance
"""
return AurPrinter(aur_package_ahriman)
@ -33,7 +33,7 @@ def configuration_printer() -> ConfigurationPrinter:
fixture for configuration printer
Returns:
ConfigurationPrinter: configuration printer test instance
ConfigurationPrinter: configuration printer test instance
"""
return ConfigurationPrinter("section", {"key_one": "value_one", "key_two": "value_two"})
@ -44,10 +44,10 @@ def package_ahriman_printer(package_ahriman: Package) -> PackagePrinter:
fixture for package printer
Args:
package_ahriman(Package): package fixture
package_ahriman(Package): package fixture
Returns:
PackagePrinter: package printer test instance
PackagePrinter: package printer test instance
"""
return PackagePrinter(package_ahriman, BuildStatus())
@ -58,7 +58,7 @@ def status_printer() -> StatusPrinter:
fixture for build status printer
Returns:
StatusPrinter: build status printer test instance
StatusPrinter: build status printer test instance
"""
return StatusPrinter(BuildStatus())
@ -69,7 +69,7 @@ def string_printer() -> StringPrinter:
fixture for any string printer
Returns:
StringPrinter: any string printer test instance
StringPrinter: any string printer test instance
"""
return StringPrinter("hello, world")
@ -80,10 +80,10 @@ def update_printer(package_ahriman: Package) -> UpdatePrinter:
fixture for build status printer
Args:
package_ahriman(Package): package fixture
package_ahriman(Package): package fixture
Returns:
UpdatePrinter: build status printer test instance
UpdatePrinter: build status printer test instance
"""
return UpdatePrinter(package_ahriman, None)
@ -94,9 +94,9 @@ def user_printer(user: User) -> UserPrinter:
fixture for user printer
Args:
user(User): user fixture
user(User): user fixture
Returns:
UserPrinter: user printer test instance
UserPrinter: user printer test instance
"""
return UserPrinter(user)

View File

@ -17,12 +17,12 @@ def cleaner(configuration: Configuration, database: SQLite, mocker: MockerFixtur
fixture for cleaner
Args:
configuration(Configuration): configuration fixture
database(SQLite): database fixture
mocker(MockerFixture): mocker object
configuration(Configuration): configuration fixture
database(SQLite): database fixture
mocker(MockerFixture): mocker object
Returns:
Cleaner: cleaner test instance
Cleaner: cleaner test instance
"""
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
return Cleaner("x86_64", configuration, database, no_report=True, unsafe=False)
@ -34,12 +34,12 @@ def executor(configuration: Configuration, database: SQLite, mocker: MockerFixtu
fixture for executor
Args:
configuration(Configuration): configuration fixture
database(SQLite): database fixture
mocker(MockerFixture): mocker object
configuration(Configuration): configuration fixture
database(SQLite): database fixture
mocker(MockerFixture): mocker object
Returns:
Executor: executor test instance
Executor: executor test instance
"""
mocker.patch("ahriman.core.repository.cleaner.Cleaner.clear_cache")
mocker.patch("ahriman.core.repository.cleaner.Cleaner.clear_chroot")
@ -55,12 +55,12 @@ def repository(configuration: Configuration, database: SQLite, mocker: MockerFix
fixture for repository
Args:
configuration(Configuration): configuration fixture
database(SQLite): database fixture
mocker(MockerFixture): mocker object
configuration(Configuration): configuration fixture
database(SQLite): database fixture
mocker(MockerFixture): mocker object
Returns:
Repository: repository test instance
Repository: repository test instance
"""
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
return Repository("x86_64", configuration, database, no_report=True, unsafe=False)
@ -72,11 +72,11 @@ def properties(configuration: Configuration, database: SQLite) -> Properties:
fixture for properties
Args:
configuration(Configuration): configuration fixture
database(SQLite): database fixture
configuration(Configuration): configuration fixture
database(SQLite): database fixture
Returns:
Properties: properties test instance
Properties: properties test instance
"""
return Properties("x86_64", configuration, database, no_report=True, unsafe=False)
@ -87,12 +87,12 @@ def update_handler(configuration: Configuration, database: SQLite, mocker: Mocke
fixture for update handler
Args:
configuration(Configuration): configuration fixture
database(SQLite): database fixture
mocker(MockerFixture): mocker object
configuration(Configuration): configuration fixture
database(SQLite): database fixture
mocker(MockerFixture): mocker object
Returns:
UpdateHandler: update handler test instance
UpdateHandler: update handler test instance
"""
mocker.patch("ahriman.core.repository.cleaner.Cleaner.clear_cache")
mocker.patch("ahriman.core.repository.cleaner.Cleaner.clear_chroot")

View File

@ -13,7 +13,7 @@ def _mock_clear(mocker: MockerFixture) -> None:
mocker helper for clear function
Args:
mocker(MockerFixture): mocker object
mocker(MockerFixture): mocker object
"""
mocker.patch("pathlib.Path.iterdir", return_value=[Path("a"), Path("b"), Path("c")])
mocker.patch("shutil.rmtree")

View File

@ -10,10 +10,10 @@ def gpg(configuration: Configuration) -> GPG:
fixture for empty GPG
Args:
configuration(Configuration): configuration fixture
configuration(Configuration): configuration fixture
Returns:
GPG: GPG test instance
GPG: GPG test instance
"""
return GPG("x86_64", configuration)
@ -24,10 +24,10 @@ def gpg_with_key(gpg: GPG) -> GPG:
fixture for correct GPG
Args:
gpg(GPG): empty GPG fixture
gpg(GPG): empty GPG fixture
Returns:
GPG: GPG test instance
GPG: GPG test instance
"""
gpg.default_key = "key"
return gpg

View File

@ -11,7 +11,7 @@ def client() -> Client:
fixture for dummy client
Returns:
Client: dummy client test instance
Client: dummy client test instance
"""
return Client()
@ -22,10 +22,10 @@ def web_client(configuration: Configuration) -> WebClient:
fixture for web client
Args:
configuration(Configuration): configuration fixture
configuration(Configuration): configuration fixture
Returns:
WebClient: web client test instance
WebClient: web client test instance
"""
configuration.set("web", "port", "8080")
return WebClient(configuration)

View File

@ -19,10 +19,10 @@ def github(configuration: Configuration) -> Github:
fixture for github synchronization
Args:
configuration(Configuration): configuration fixture
configuration(Configuration): configuration fixture
Returns:
Github: github test instance
Github: github test instance
"""
return Github("x86_64", configuration, "github:x86_64")
@ -33,7 +33,7 @@ def github_release() -> Dict[str, Any]:
fixture for the github release object
Returns:
Dict[str, Any]: github test release object
Dict[str, Any]: github test release object
"""
return {
"url": "release_url",
@ -55,10 +55,10 @@ def rsync(configuration: Configuration) -> Rsync:
fixture for rsync synchronization
Args:
configuration(Configuration): configuration fixture
configuration(Configuration): configuration fixture
Returns:
Rsync: rsync test instance
Rsync: rsync test instance
"""
return Rsync("x86_64", configuration, "rsync")
@ -69,10 +69,10 @@ def s3(configuration: Configuration) -> S3:
fixture for S3 synchronization
Args:
configuration(Configuration): configuration fixture
configuration(Configuration): configuration fixture
Returns:
S3: S3 test instance
S3: S3 test instance
"""
return S3("x86_64", configuration, "customs3")
@ -83,7 +83,7 @@ def s3_remote_objects() -> List[_s3_object]:
fixture for boto3 like S3 objects
Returns:
List[_s3_object]: boto3 like S3 objects test instance
List[_s3_object]: boto3 like S3 objects test instance
"""
delete_mock = MagicMock()
return list(map(lambda item: _s3_object(f"x86_64/{item}", f"\"{item}\"", delete_mock), ["a", "b", "c"]))

View File

@ -18,7 +18,7 @@ def build_status_failed() -> BuildStatus:
build result fixture with failed status
Returns:
BuildStatus: failed build status test instance
BuildStatus: failed build status test instance
"""
return BuildStatus(BuildStatusEnum.Failed, 42)
@ -29,7 +29,7 @@ def counters() -> Counters:
counters fixture
Returns:
Counters: counters test instance
Counters: counters test instance
"""
return Counters(total=10,
unknown=1,
@ -45,10 +45,10 @@ def internal_status(counters: Counters) -> InternalStatus:
internal status fixture
Args:
counters(Counters): counters fixture
counters(Counters): counters fixture
Returns:
InternalStatus: internal status test instance
InternalStatus: internal status test instance
"""
return InternalStatus(architecture="x86_64",
packages=counters,
@ -62,7 +62,7 @@ def package_tpacpi_bat_git() -> Package:
git package fixture
Returns:
Package: git package test instance
Package: git package test instance
"""
return Package(
base="tpacpi-bat-git",
@ -77,10 +77,10 @@ def pyalpm_handle(pyalpm_package_ahriman: MagicMock) -> MagicMock:
mock object for pyalpm
Args:
pyalpm_package_ahriman(MagicMock): mock object for pyalpm package
pyalpm_package_ahriman(MagicMock): mock object for pyalpm package
Returns:
MagicMock: pyalpm mock
MagicMock: pyalpm mock
"""
mock = MagicMock()
mock.handle.load_pkg.return_value = pyalpm_package_ahriman
@ -93,10 +93,10 @@ def pyalpm_package_ahriman(package_ahriman: Package) -> MagicMock:
mock object for pyalpm package
Args:
package_ahriman(Package): package fixture
package_ahriman(Package): package fixture
Returns:
MagicMock: pyalpm package mock
MagicMock: pyalpm package mock
"""
mock = MagicMock()
type(mock).base = PropertyMock(return_value=package_ahriman.base)
@ -113,10 +113,10 @@ def pyalpm_package_description_ahriman(package_description_ahriman: PackageDescr
mock object for pyalpm package description
Args:
package_description_ahriman(PackageDescription): package description fixture
package_description_ahriman(PackageDescription): package description fixture
Returns:
MagicMock: pyalpm package description mock
MagicMock: pyalpm package description mock
"""
mock = MagicMock()
type(mock).arch = PropertyMock(return_value=package_description_ahriman.architecture)
@ -138,6 +138,6 @@ def user_identity() -> UserIdentity:
identity fixture
Returns:
UserIdentity: user identity test instance
UserIdentity: user identity test instance
"""
return UserIdentity("username", int(time.time()) + 30)

View File

@ -14,10 +14,10 @@ def _get_aur_data(resource_path_root: Path) -> Dict[str, Any]:
load package description from resource file
Args:
resource_path_root(Path): path to resource root
resource_path_root(Path): path to resource root
Returns:
Dict[str, Any]: json descriptor
Dict[str, Any]: json descriptor
"""
response = (resource_path_root / "models" / "package_ahriman_aur").read_text()
return json.loads(response)["results"][0]
@ -28,10 +28,10 @@ def _get_official_data(resource_path_root: Path) -> Dict[str, Any]:
load package description from resource file
Args:
resource_path_root(Path): path to resource root
resource_path_root(Path): path to resource root
Returns:
Dict[str, Any]: json descriptor
Dict[str, Any]: json descriptor
"""
response = (resource_path_root / "models" / "package_akonadi_aur").read_text()
return json.loads(response)["results"][0]

View File

@ -11,11 +11,11 @@ def _is_file_mock(is_any_file: bool, is_pkgbuild: bool) -> Callable[[Path], bool
helper to mock is_file method
Args:
is_any_file(bool): value which will be return for any file
is_pkgbuild(bool): value which will be return if PKGBUILD like path asked
is_any_file(bool): value which will be return for any file
is_pkgbuild(bool): value which will be return if PKGBUILD like path asked
Returns:
Callable[[Path], bool]: side effect function for the mocker object
Callable[[Path], bool]: side effect function for the mocker object
"""
side_effect: Callable[[Path], bool] = lambda source: is_pkgbuild if source.name == "PKGBUILD" else is_any_file
return side_effect

View File

@ -16,11 +16,11 @@ def _get_owner(root: Path, same: bool) -> Callable[[Path], Tuple[int, int]]:
mocker function for owner definition
Args:
root(Path): root directory
same(bool): if True then returns the same as root directory and different otherwise
root(Path): root directory
same(bool): if True then returns the same as root directory and different otherwise
Returns:
Callable[[Path], Tuple[int, int]]: function which can define ownership
Callable[[Path], Tuple[int, int]]: function which can define ownership
"""
root_owner = (42, 42)
nonroot_owner = (42, 42) if same else (1, 1)

View File

@ -23,14 +23,14 @@ def request(app: web.Application, path: str, method: str, json: Any = None, data
request generator helper
Args:
app(web.Application): application fixture
path(str): path for the request
method(str): method for the request
json(Any, optional): json payload of the request (Default value = None)
data(Any, optional): form data payload of the request (Default value = None)
app(web.Application): application fixture
path(str): path for the request
method(str): method for the request
json(Any, optional): json payload of the request (Default value = None)
data(Any, optional): form data payload of the request (Default value = None)
Returns:
_request: dummy request object
_request: dummy request object
"""
return _request(app, path, method, json, data)
@ -42,13 +42,13 @@ def application(configuration: Configuration, spawner: Spawn, database: SQLite,
application fixture
Args:
configuration(Configuration): configuration fixture
spawner(Spawn): spawner fixture
database(SQLite): database fixture
mocker(MockerFixture): mocker object
configuration(Configuration): configuration fixture
spawner(Spawn): spawner fixture
database(SQLite): database fixture
mocker(MockerFixture): mocker object
Returns:
web.Application: application test instance
web.Application: application test instance
"""
mocker.patch("ahriman.core.database.sqlite.SQLite.load", return_value=database)
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
@ -63,14 +63,14 @@ def application_with_auth(configuration: Configuration, user: User, spawner: Spa
application fixture with auth enabled
Args:
configuration(Configuration): configuration fixture
user(User): user descriptor fixture
spawner(Spawn): spawner fixture
database(SQLite): database fixture
mocker(MockerFixture): mocker object
configuration(Configuration): configuration fixture
user(User): user descriptor fixture
spawner(Spawn): spawner fixture
database(SQLite): database fixture
mocker(MockerFixture): mocker object
Returns:
web.Application: application test instance
web.Application: application test instance
"""
configuration.set_option("auth", "target", "configuration")
mocker.patch("ahriman.core.database.sqlite.SQLite.load", return_value=database)
@ -91,14 +91,14 @@ def application_with_debug(configuration: Configuration, user: User, spawner: Sp
application fixture with debug enabled
Args:
configuration(Configuration): configuration fixture
user(User): user descriptor fixture
spawner(Spawn): spawner fixture
database(SQLite): database fixture
mocker(MockerFixture): mocker object
configuration(Configuration): configuration fixture
user(User): user descriptor fixture
spawner(Spawn): spawner fixture
database(SQLite): database fixture
mocker(MockerFixture): mocker object
Returns:
web.Application: application test instance
web.Application: application test instance
"""
configuration.set_option("web", "debug", "yes")
mocker.patch("ahriman.core.database.sqlite.SQLite.load", return_value=database)

View File

@ -13,12 +13,12 @@ def authorization_policy(configuration: Configuration, database: SQLite, user: U
fixture for authorization policy
Args:
configuration(Configuration): configuration fixture
database(SQLite): database fixture
user(User): user fixture
configuration(Configuration): configuration fixture
database(SQLite): database fixture
user(User): user fixture
Returns:
AuthorizationPolicy: authorization policy fixture
AuthorizationPolicy: authorization policy fixture
"""
configuration.set_option("auth", "target", "configuration")
validator = Auth.load(configuration, database)

View File

@ -16,10 +16,10 @@ def _identity(username: str) -> str:
generate identity from user
Args:
username(str): name of the user
username(str): name of the user
Returns:
str: user identity string
str: user identity string
"""
return f"{username} {UserIdentity.expire_when(60)}"

View File

@ -15,10 +15,10 @@ def _extract_body(response: Any) -> Any:
extract json body from given object
Args:
response(Any): response (any actually) object
response(Any): response (any actually) object
Returns:
Any: body key from the object converted to json
Any: body key from the object converted to json
"""
return json.loads(getattr(response, "body"))

View File

@ -17,10 +17,10 @@ def base(application: web.Application) -> BaseView:
base view fixture
Args:
application(web.Application): application fixture
application(web.Application): application fixture
Returns:
BaseView: generated base view fixture
BaseView: generated base view fixture
"""
return BaseView(pytest.helpers.request(application, "", ""))
@ -32,13 +32,13 @@ def client(application: web.Application, event_loop: BaseEventLoop,
web client fixture
Args:
application(web.Application): application fixture
event_loop(BaseEventLoop): context event loop
aiohttp_client(Any): aiohttp client fixture
mocker(MockerFixture): mocker object
application(web.Application): application fixture
event_loop(BaseEventLoop): context event loop
aiohttp_client(Any): aiohttp client fixture
mocker(MockerFixture): mocker object
Returns:
TestClient: web client test instance
TestClient: web client test instance
"""
mocker.patch("pathlib.Path.iterdir", return_value=[])
return event_loop.run_until_complete(aiohttp_client(application))
@ -51,13 +51,13 @@ def client_with_auth(application_with_auth: web.Application, event_loop: BaseEve
web client fixture with full authorization functions
Args:
application_with_auth(web.Application): application fixture
event_loop(BaseEventLoop): context event loop
aiohttp_client(Any): aiohttp client fixture
mocker(MockerFixture): mocker object
application_with_auth(web.Application): application fixture
event_loop(BaseEventLoop): context event loop
aiohttp_client(Any): aiohttp client fixture
mocker(MockerFixture): mocker object
Returns:
TestClient: web client test instance
TestClient: web client test instance
"""
mocker.patch("pathlib.Path.iterdir", return_value=[])
return event_loop.run_until_complete(aiohttp_client(application_with_auth))
@ -70,13 +70,13 @@ def client_with_oauth_auth(application_with_auth: web.Application, event_loop: B
web client fixture with full authorization functions
Args:
application_with_auth(web.Application): application fixture
event_loop(BaseEventLoop): context event loop
aiohttp_client(Any): aiohttp client fixture
mocker(MockerFixture): mocker object
application_with_auth(web.Application): application fixture
event_loop(BaseEventLoop): context event loop
aiohttp_client(Any): aiohttp client fixture
mocker(MockerFixture): mocker object
Returns:
TestClient: web client test instance
TestClient: web client test instance
"""
mocker.patch("pathlib.Path.iterdir", return_value=[])
application_with_auth["validator"] = MagicMock(spec=OAuth)