mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-07-30 06:09:56 +00:00
shorten public imports
This commit is contained in:
@ -1,9 +1,6 @@
|
||||
import pytest
|
||||
|
||||
from ahriman.core.alpm.remote.aur import AUR
|
||||
from ahriman.core.alpm.remote.official import Official
|
||||
from ahriman.core.alpm.remote.official_syncdb import OfficialSyncdb
|
||||
from ahriman.core.alpm.remote.remote import Remote
|
||||
from ahriman.core.alpm.remote import AUR, Official, OfficialSyncdb, Remote
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
@ -7,7 +7,7 @@ from pytest_mock import MockerFixture
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from ahriman.core.alpm.pacman import Pacman
|
||||
from ahriman.core.alpm.remote.aur import AUR
|
||||
from ahriman.core.alpm.remote import AUR
|
||||
from ahriman.core.exceptions import InvalidPackageInfo
|
||||
from ahriman.models.aur_package import AURPackage
|
||||
|
||||
@ -131,7 +131,7 @@ def test_package_info(aur: AUR, aur_package_ahriman: AURPackage, pacman: Pacman,
|
||||
"""
|
||||
must make request for info
|
||||
"""
|
||||
request_mock = mocker.patch("ahriman.core.alpm.remote.aur.AUR.make_request", return_value=[aur_package_ahriman])
|
||||
request_mock = mocker.patch("ahriman.core.alpm.remote.AUR.make_request", return_value=[aur_package_ahriman])
|
||||
assert aur.package_info(aur_package_ahriman.name, pacman=pacman) == aur_package_ahriman
|
||||
request_mock.assert_called_once_with("info", aur_package_ahriman.name)
|
||||
|
||||
@ -140,6 +140,6 @@ def test_package_search(aur: AUR, aur_package_ahriman: AURPackage, pacman: Pacma
|
||||
"""
|
||||
must make request for search
|
||||
"""
|
||||
request_mock = mocker.patch("ahriman.core.alpm.remote.aur.AUR.make_request", return_value=[aur_package_ahriman])
|
||||
request_mock = mocker.patch("ahriman.core.alpm.remote.AUR.make_request", return_value=[aur_package_ahriman])
|
||||
assert aur.package_search(aur_package_ahriman.name, pacman=pacman) == [aur_package_ahriman]
|
||||
request_mock.assert_called_once_with("search", aur_package_ahriman.name, by="name-desc")
|
||||
|
@ -7,7 +7,7 @@ from pytest_mock import MockerFixture
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from ahriman.core.alpm.pacman import Pacman
|
||||
from ahriman.core.alpm.remote.official import Official
|
||||
from ahriman.core.alpm.remote import Official
|
||||
from ahriman.core.exceptions import InvalidPackageInfo
|
||||
from ahriman.models.aur_package import AURPackage
|
||||
|
||||
@ -111,7 +111,7 @@ def test_package_info(official: Official, aur_package_akonadi: AURPackage, pacma
|
||||
"""
|
||||
must make request for info
|
||||
"""
|
||||
request_mock = mocker.patch("ahriman.core.alpm.remote.official.Official.make_request",
|
||||
request_mock = mocker.patch("ahriman.core.alpm.remote.Official.make_request",
|
||||
return_value=[aur_package_akonadi])
|
||||
assert official.package_info(aur_package_akonadi.name, pacman=pacman) == aur_package_akonadi
|
||||
request_mock.assert_called_once_with(aur_package_akonadi.name, by="name")
|
||||
@ -122,7 +122,7 @@ def test_package_search(official: Official, aur_package_akonadi: AURPackage, pac
|
||||
"""
|
||||
must make request for search
|
||||
"""
|
||||
request_mock = mocker.patch("ahriman.core.alpm.remote.official.Official.make_request",
|
||||
request_mock = mocker.patch("ahriman.core.alpm.remote.Official.make_request",
|
||||
return_value=[aur_package_akonadi])
|
||||
assert official.package_search(aur_package_akonadi.name, pacman=pacman) == [aur_package_akonadi]
|
||||
request_mock.assert_called_once_with(aur_package_akonadi.name, by="q")
|
||||
|
@ -1,7 +1,7 @@
|
||||
from pytest_mock import MockerFixture
|
||||
|
||||
from ahriman.core.alpm.pacman import Pacman
|
||||
from ahriman.core.alpm.remote.official_syncdb import OfficialSyncdb
|
||||
from ahriman.core.alpm.remote import OfficialSyncdb
|
||||
from ahriman.models.aur_package import AURPackage
|
||||
|
||||
|
||||
|
@ -4,7 +4,7 @@ from pytest_mock import MockerFixture
|
||||
from unittest import mock
|
||||
|
||||
from ahriman.core.alpm.pacman import Pacman
|
||||
from ahriman.core.alpm.remote.remote import Remote
|
||||
from ahriman.core.alpm.remote import Remote
|
||||
from ahriman.models.aur_package import AURPackage
|
||||
|
||||
|
||||
@ -12,7 +12,7 @@ def test_info(pacman: Pacman, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must call info method
|
||||
"""
|
||||
info_mock = mocker.patch("ahriman.core.alpm.remote.remote.Remote.package_info")
|
||||
info_mock = mocker.patch("ahriman.core.alpm.remote.Remote.package_info")
|
||||
Remote.info("ahriman", pacman=pacman)
|
||||
info_mock.assert_called_once_with("ahriman", pacman=pacman)
|
||||
|
||||
@ -22,7 +22,7 @@ def test_multisearch(aur_package_ahriman: AURPackage, pacman: Pacman, mocker: Mo
|
||||
must search in AUR with multiple words
|
||||
"""
|
||||
terms = ["ahriman", "is", "cool"]
|
||||
search_mock = mocker.patch("ahriman.core.alpm.remote.remote.Remote.search", return_value=[aur_package_ahriman])
|
||||
search_mock = mocker.patch("ahriman.core.alpm.remote.Remote.search", return_value=[aur_package_ahriman])
|
||||
|
||||
assert Remote.multisearch(*terms, pacman=pacman) == [aur_package_ahriman]
|
||||
search_mock.assert_has_calls([mock.call("ahriman", pacman=pacman), mock.call("cool", pacman=pacman)])
|
||||
@ -33,7 +33,7 @@ def test_multisearch_empty(pacman: Pacman, mocker: MockerFixture) -> None:
|
||||
must return empty list if no long terms supplied
|
||||
"""
|
||||
terms = ["it", "is"]
|
||||
search_mock = mocker.patch("ahriman.core.alpm.remote.remote.Remote.search")
|
||||
search_mock = mocker.patch("ahriman.core.alpm.remote.Remote.search")
|
||||
|
||||
assert Remote.multisearch(*terms, pacman=pacman) == []
|
||||
search_mock.assert_not_called()
|
||||
@ -43,7 +43,7 @@ def test_multisearch_single(aur_package_ahriman: AURPackage, pacman: Pacman, moc
|
||||
"""
|
||||
must search in AUR with one word
|
||||
"""
|
||||
search_mock = mocker.patch("ahriman.core.alpm.remote.remote.Remote.search", return_value=[aur_package_ahriman])
|
||||
search_mock = mocker.patch("ahriman.core.alpm.remote.Remote.search", return_value=[aur_package_ahriman])
|
||||
assert Remote.multisearch("ahriman", pacman=pacman) == [aur_package_ahriman]
|
||||
search_mock.assert_called_once_with("ahriman", pacman=pacman)
|
||||
|
||||
@ -68,7 +68,7 @@ def test_search(pacman: Pacman, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must call search method
|
||||
"""
|
||||
search_mock = mocker.patch("ahriman.core.alpm.remote.remote.Remote.package_search")
|
||||
search_mock = mocker.patch("ahriman.core.alpm.remote.Remote.package_search")
|
||||
Remote.search("ahriman", pacman=pacman)
|
||||
search_mock.assert_called_once_with("ahriman", pacman=pacman)
|
||||
|
||||
|
@ -1,9 +1,8 @@
|
||||
import pytest
|
||||
|
||||
from ahriman.core.auth.mapping import Mapping
|
||||
from ahriman.core.auth.oauth import OAuth
|
||||
from ahriman.core.auth import Mapping, OAuth
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.database.sqlite import SQLite
|
||||
from ahriman.core.database import SQLite
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
@ -1,8 +1,6 @@
|
||||
from ahriman.core.auth.auth import Auth
|
||||
from ahriman.core.auth.mapping import Mapping
|
||||
from ahriman.core.auth.oauth import OAuth
|
||||
from ahriman.core.auth import Auth, Mapping, OAuth
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.database.sqlite import SQLite
|
||||
from ahriman.core.database import SQLite
|
||||
from ahriman.models.user import User
|
||||
from ahriman.models.user_access import UserAccess
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
from pytest_mock import MockerFixture
|
||||
|
||||
from ahriman.core.auth.mapping import Mapping
|
||||
from ahriman.core.auth import Mapping
|
||||
from ahriman.models.user import User
|
||||
from ahriman.models.user_access import UserAccess
|
||||
|
||||
@ -11,7 +11,7 @@ async def test_check_credentials(mapping: Mapping, user: User, mocker: MockerFix
|
||||
"""
|
||||
current_password = user.password
|
||||
user = user.hash_password(mapping.salt)
|
||||
mocker.patch("ahriman.core.database.sqlite.SQLite.user_get", return_value=user)
|
||||
mocker.patch("ahriman.core.database.SQLite.user_get", return_value=user)
|
||||
assert await mapping.check_credentials(user.username, current_password)
|
||||
# here password is hashed so it is invalid
|
||||
assert not await mapping.check_credentials(user.username, user.password)
|
||||
@ -37,7 +37,7 @@ def test_get_user(mapping: Mapping, user: User, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must return user from storage by username
|
||||
"""
|
||||
mocker.patch("ahriman.core.database.sqlite.SQLite.user_get", return_value=user)
|
||||
mocker.patch("ahriman.core.database.SQLite.user_get", return_value=user)
|
||||
assert mapping.get_user(user.username) == user
|
||||
|
||||
|
||||
@ -45,7 +45,7 @@ def test_get_user_normalized(mapping: Mapping, user: User, mocker: MockerFixture
|
||||
"""
|
||||
must return user from storage by username case-insensitive
|
||||
"""
|
||||
mocker.patch("ahriman.core.database.sqlite.SQLite.user_get", return_value=user)
|
||||
mocker.patch("ahriman.core.database.SQLite.user_get", return_value=user)
|
||||
assert mapping.get_user(user.username.upper()) == user
|
||||
|
||||
|
||||
@ -60,7 +60,7 @@ async def test_known_username(mapping: Mapping, user: User, mocker: MockerFixtur
|
||||
"""
|
||||
must allow only known users
|
||||
"""
|
||||
mocker.patch("ahriman.core.database.sqlite.SQLite.user_get", return_value=user)
|
||||
mocker.patch("ahriman.core.database.SQLite.user_get", return_value=user)
|
||||
assert await mapping.known_username(user.username)
|
||||
|
||||
|
||||
@ -69,7 +69,7 @@ async def test_known_username_unknown(mapping: Mapping, user: User, mocker: Mock
|
||||
must not allow only known users
|
||||
"""
|
||||
assert not await mapping.known_username(None)
|
||||
mocker.patch("ahriman.core.database.sqlite.SQLite.user_get", return_value=None)
|
||||
mocker.patch("ahriman.core.database.SQLite.user_get", return_value=None)
|
||||
assert not await mapping.known_username(user.password)
|
||||
|
||||
|
||||
@ -77,6 +77,6 @@ async def test_verify_access(mapping: Mapping, user: User, mocker: MockerFixture
|
||||
"""
|
||||
must verify user access
|
||||
"""
|
||||
mocker.patch("ahriman.core.database.sqlite.SQLite.user_get", return_value=user)
|
||||
mocker.patch("ahriman.core.database.SQLite.user_get", return_value=user)
|
||||
assert await mapping.verify_access(user.username, user.access, None)
|
||||
assert not await mapping.verify_access(user.username, UserAccess.Write, None)
|
||||
|
@ -3,7 +3,7 @@ import pytest
|
||||
|
||||
from pytest_mock import MockerFixture
|
||||
|
||||
from ahriman.core.auth.oauth import OAuth
|
||||
from ahriman.core.auth import OAuth
|
||||
from ahriman.core.exceptions import InvalidOption
|
||||
|
||||
|
||||
|
@ -2,7 +2,7 @@ from pathlib import Path
|
||||
from pytest_mock import MockerFixture
|
||||
|
||||
from ahriman.core.build_tools.task import Task
|
||||
from ahriman.core.database.sqlite import SQLite
|
||||
from ahriman.core.database import SQLite
|
||||
|
||||
|
||||
def test_build(task_ahriman: Task, mocker: MockerFixture) -> None:
|
||||
|
@ -1,4 +1,4 @@
|
||||
from ahriman.core.database.sqlite import SQLite
|
||||
from ahriman.core.database import SQLite
|
||||
from ahriman.models.user import User
|
||||
from ahriman.models.user_access import UserAccess
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
from ahriman.core.database.sqlite import SQLite
|
||||
from ahriman.core.database import SQLite
|
||||
from ahriman.models.package import Package
|
||||
|
||||
|
||||
|
@ -3,7 +3,7 @@ import sqlite3
|
||||
from pytest_mock import MockerFixture
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from ahriman.core.database.sqlite import SQLite
|
||||
from ahriman.core.database import SQLite
|
||||
|
||||
|
||||
def test_factory(database: SQLite) -> None:
|
||||
|
@ -4,7 +4,7 @@ from pytest_mock import MockerFixture
|
||||
from sqlite3 import Connection
|
||||
from unittest import mock
|
||||
|
||||
from ahriman.core.database.sqlite import SQLite
|
||||
from ahriman.core.database import SQLite
|
||||
from ahriman.models.build_status import BuildStatus, BuildStatusEnum
|
||||
from ahriman.models.package import Package
|
||||
from ahriman.models.package_source import PackageSource
|
||||
@ -97,8 +97,8 @@ def test_package_remove(database: SQLite, package_ahriman: Package, mocker: Mock
|
||||
"""
|
||||
must totally remove package from the database
|
||||
"""
|
||||
remove_package_mock = mocker.patch("ahriman.core.database.sqlite.SQLite._package_remove_package_base")
|
||||
remove_packages_mock = mocker.patch("ahriman.core.database.sqlite.SQLite._package_remove_packages")
|
||||
remove_package_mock = mocker.patch("ahriman.core.database.SQLite._package_remove_package_base")
|
||||
remove_packages_mock = mocker.patch("ahriman.core.database.SQLite._package_remove_packages")
|
||||
|
||||
database.package_remove(package_ahriman.base)
|
||||
remove_package_mock.assert_called_once_with(pytest.helpers.anyvar(int), package_ahriman.base)
|
||||
@ -110,10 +110,10 @@ def test_package_update(database: SQLite, package_ahriman: Package, mocker: Mock
|
||||
must update package status
|
||||
"""
|
||||
status = BuildStatus()
|
||||
insert_base_mock = mocker.patch("ahriman.core.database.sqlite.SQLite._package_update_insert_base")
|
||||
insert_status_mock = mocker.patch("ahriman.core.database.sqlite.SQLite._package_update_insert_status")
|
||||
insert_packages_mock = mocker.patch("ahriman.core.database.sqlite.SQLite._package_update_insert_packages")
|
||||
remove_packages_mock = mocker.patch("ahriman.core.database.sqlite.SQLite._package_remove_packages")
|
||||
insert_base_mock = mocker.patch("ahriman.core.database.SQLite._package_update_insert_base")
|
||||
insert_status_mock = mocker.patch("ahriman.core.database.SQLite._package_update_insert_status")
|
||||
insert_packages_mock = mocker.patch("ahriman.core.database.SQLite._package_update_insert_packages")
|
||||
remove_packages_mock = mocker.patch("ahriman.core.database.SQLite._package_remove_packages")
|
||||
|
||||
database.package_update(package_ahriman, status)
|
||||
insert_base_mock.assert_called_once_with(pytest.helpers.anyvar(int), package_ahriman)
|
||||
@ -127,10 +127,10 @@ def test_packages_get(database: SQLite, package_ahriman: Package, mocker: Mocker
|
||||
"""
|
||||
must return all packages
|
||||
"""
|
||||
select_bases_mock = mocker.patch("ahriman.core.database.sqlite.SQLite._packages_get_select_package_bases",
|
||||
select_bases_mock = mocker.patch("ahriman.core.database.SQLite._packages_get_select_package_bases",
|
||||
return_value={package_ahriman.base: package_ahriman})
|
||||
select_packages_mock = mocker.patch("ahriman.core.database.sqlite.SQLite._packages_get_select_packages")
|
||||
select_statuses_mock = mocker.patch("ahriman.core.database.sqlite.SQLite._packages_get_select_statuses")
|
||||
select_packages_mock = mocker.patch("ahriman.core.database.SQLite._packages_get_select_packages")
|
||||
select_statuses_mock = mocker.patch("ahriman.core.database.SQLite._packages_get_select_statuses")
|
||||
|
||||
database.packages_get()
|
||||
select_bases_mock.assert_called_once_with(pytest.helpers.anyvar(int))
|
||||
|
@ -1,4 +1,4 @@
|
||||
from ahriman.core.database.sqlite import SQLite
|
||||
from ahriman.core.database import SQLite
|
||||
from ahriman.models.package import Package
|
||||
|
||||
|
||||
|
@ -3,14 +3,14 @@ import pytest
|
||||
from pytest_mock import MockerFixture
|
||||
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.database.sqlite import SQLite
|
||||
from ahriman.core.database import SQLite
|
||||
|
||||
|
||||
def test_load(configuration: Configuration, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must correctly load instance
|
||||
"""
|
||||
init_mock = mocker.patch("ahriman.core.database.sqlite.SQLite.init")
|
||||
init_mock = mocker.patch("ahriman.core.database.SQLite.init")
|
||||
SQLite.load(configuration)
|
||||
init_mock.assert_called_once_with(configuration)
|
||||
|
||||
|
@ -1,12 +1,6 @@
|
||||
import pytest
|
||||
|
||||
from ahriman.core.formatters.aur_printer import AurPrinter
|
||||
from ahriman.core.formatters.configuration_printer import ConfigurationPrinter
|
||||
from ahriman.core.formatters.package_printer import PackagePrinter
|
||||
from ahriman.core.formatters.status_printer import StatusPrinter
|
||||
from ahriman.core.formatters.string_printer import StringPrinter
|
||||
from ahriman.core.formatters.update_printer import UpdatePrinter
|
||||
from ahriman.core.formatters.user_printer import UserPrinter
|
||||
from ahriman.core.formatters import AurPrinter, ConfigurationPrinter, PackagePrinter, StatusPrinter, StringPrinter, UpdatePrinter, UserPrinter
|
||||
from ahriman.models.aur_package import AURPackage
|
||||
from ahriman.models.build_status import BuildStatus
|
||||
from ahriman.models.package import Package
|
||||
|
@ -1,4 +1,4 @@
|
||||
from ahriman.core.formatters.aur_printer import AurPrinter
|
||||
from ahriman.core.formatters import AurPrinter
|
||||
|
||||
|
||||
def test_properties(aur_package_ahriman_printer: AurPrinter) -> None:
|
||||
|
@ -1,6 +1,6 @@
|
||||
import pytest
|
||||
|
||||
from ahriman.core.formatters.build_printer import BuildPrinter
|
||||
from ahriman.core.formatters import BuildPrinter
|
||||
from ahriman.models.package import Package
|
||||
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
from ahriman.core.formatters.configuration_printer import ConfigurationPrinter
|
||||
from ahriman.core.formatters import ConfigurationPrinter
|
||||
|
||||
|
||||
def test_properties(configuration_printer: ConfigurationPrinter) -> None:
|
||||
|
@ -1,4 +1,4 @@
|
||||
from ahriman.core.formatters.package_printer import PackagePrinter
|
||||
from ahriman.core.formatters import PackagePrinter
|
||||
|
||||
|
||||
def test_properties(package_ahriman_printer: PackagePrinter) -> None:
|
||||
|
@ -1,7 +1,7 @@
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from ahriman.core.formatters.package_printer import PackagePrinter
|
||||
from ahriman.core.formatters.printer import Printer
|
||||
from ahriman.core.formatters import PackagePrinter
|
||||
from ahriman.core.formatters import Printer
|
||||
|
||||
|
||||
def test_print(package_ahriman_printer: PackagePrinter) -> None:
|
||||
|
@ -1,4 +1,4 @@
|
||||
from ahriman.core.formatters.status_printer import StatusPrinter
|
||||
from ahriman.core.formatters import StatusPrinter
|
||||
|
||||
|
||||
def test_properties(status_printer: StatusPrinter) -> None:
|
||||
|
@ -1,4 +1,4 @@
|
||||
from ahriman.core.formatters.string_printer import StringPrinter
|
||||
from ahriman.core.formatters import StringPrinter
|
||||
|
||||
|
||||
def test_properties(string_printer: StringPrinter) -> None:
|
||||
|
@ -1,4 +1,4 @@
|
||||
from ahriman.core.formatters.update_printer import UpdatePrinter
|
||||
from ahriman.core.formatters import UpdatePrinter
|
||||
|
||||
|
||||
def test_properties(update_printer: UpdatePrinter) -> None:
|
||||
|
@ -1,4 +1,4 @@
|
||||
from ahriman.core.formatters.user_printer import UserPrinter
|
||||
from ahriman.core.formatters import UserPrinter
|
||||
|
||||
|
||||
def test_properties(user_printer: UserPrinter) -> None:
|
||||
|
@ -2,7 +2,7 @@ from pytest_mock import MockerFixture
|
||||
from unittest import mock
|
||||
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.report.console import Console
|
||||
from ahriman.core.report import Console
|
||||
from ahriman.models.package import Package
|
||||
from ahriman.models.result import Result
|
||||
|
||||
@ -12,7 +12,7 @@ def test_generate(configuration: Configuration, result: Result, package_python_s
|
||||
"""
|
||||
must print result to stdout
|
||||
"""
|
||||
print_mock = mocker.patch("ahriman.core.formatters.printer.Printer.print")
|
||||
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
|
||||
result.add_failed(package_python_schedule)
|
||||
report = Console("x86_64", configuration, "console")
|
||||
|
||||
|
@ -3,7 +3,7 @@ import pytest
|
||||
from pytest_mock import MockerFixture
|
||||
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.report.email import Email
|
||||
from ahriman.core.report import Email
|
||||
from ahriman.models.package import Package
|
||||
from ahriman.models.result import Result
|
||||
|
||||
@ -90,7 +90,7 @@ def test_generate(configuration: Configuration, package_ahriman: Package, mocker
|
||||
"""
|
||||
must generate report
|
||||
"""
|
||||
send_mock = mocker.patch("ahriman.core.report.email.Email._send")
|
||||
send_mock = mocker.patch("ahriman.core.report.Email._send")
|
||||
|
||||
report = Email("x86_64", configuration, "email")
|
||||
report.generate([package_ahriman], Result())
|
||||
@ -102,7 +102,7 @@ def test_generate_with_built(configuration: Configuration, package_ahriman: Pack
|
||||
"""
|
||||
must generate report with built packages
|
||||
"""
|
||||
send_mock = mocker.patch("ahriman.core.report.email.Email._send")
|
||||
send_mock = mocker.patch("ahriman.core.report.Email._send")
|
||||
|
||||
report = Email("x86_64", configuration, "email")
|
||||
report.generate([package_ahriman], result)
|
||||
@ -117,7 +117,7 @@ def test_generate_with_built_and_full_path(
|
||||
"""
|
||||
must generate report with built packages and full packages lists
|
||||
"""
|
||||
send_mock = mocker.patch("ahriman.core.report.email.Email._send")
|
||||
send_mock = mocker.patch("ahriman.core.report.Email._send")
|
||||
|
||||
report = Email("x86_64", configuration, "email")
|
||||
report.full_template_path = report.template_path
|
||||
@ -130,7 +130,7 @@ def test_generate_no_empty(configuration: Configuration, package_ahriman: Packag
|
||||
must not generate report with built packages if no_empty_report is set
|
||||
"""
|
||||
configuration.set_option("email", "no_empty_report", "yes")
|
||||
send_mock = mocker.patch("ahriman.core.report.email.Email._send")
|
||||
send_mock = mocker.patch("ahriman.core.report.Email._send")
|
||||
|
||||
report = Email("x86_64", configuration, "email")
|
||||
report.generate([package_ahriman], Result())
|
||||
@ -143,7 +143,7 @@ def test_generate_no_empty_with_built(configuration: Configuration, package_ahri
|
||||
must generate report with built packages if no_empty_report is set
|
||||
"""
|
||||
configuration.set_option("email", "no_empty_report", "yes")
|
||||
send_mock = mocker.patch("ahriman.core.report.email.Email._send")
|
||||
send_mock = mocker.patch("ahriman.core.report.Email._send")
|
||||
|
||||
report = Email("x86_64", configuration, "email")
|
||||
report.generate([package_ahriman], result)
|
||||
|
@ -3,7 +3,7 @@ import pytest
|
||||
from pytest_mock import MockerFixture
|
||||
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.report.html import HTML
|
||||
from ahriman.core.report import HTML
|
||||
from ahriman.models.package import Package
|
||||
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.report.jinja_template import JinjaTemplate
|
||||
from ahriman.core.report import JinjaTemplate
|
||||
from ahriman.models.package import Package
|
||||
from ahriman.models.result import Result
|
||||
|
||||
|
@ -4,7 +4,7 @@ from pytest_mock import MockerFixture
|
||||
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.exceptions import ReportFailed
|
||||
from ahriman.core.report.report import Report
|
||||
from ahriman.core.report import Report
|
||||
from ahriman.models.report_settings import ReportSettings
|
||||
from ahriman.models.result import Result
|
||||
|
||||
@ -13,7 +13,7 @@ def test_report_failure(configuration: Configuration, mocker: MockerFixture) ->
|
||||
"""
|
||||
must raise ReportFailed on errors
|
||||
"""
|
||||
mocker.patch("ahriman.core.report.html.HTML.generate", side_effect=Exception())
|
||||
mocker.patch("ahriman.core.report.HTML.generate", side_effect=Exception())
|
||||
with pytest.raises(ReportFailed):
|
||||
Report.load("x86_64", configuration, "html").run([], Result())
|
||||
|
||||
@ -23,7 +23,7 @@ def test_report_dummy(configuration: Configuration, result: Result, mocker: Mock
|
||||
must construct dummy report class
|
||||
"""
|
||||
mocker.patch("ahriman.models.report_settings.ReportSettings.from_option", return_value=ReportSettings.Disabled)
|
||||
report_mock = mocker.patch("ahriman.core.report.report.Report.generate")
|
||||
report_mock = mocker.patch("ahriman.core.report.Report.generate")
|
||||
Report.load("x86_64", configuration, "disabled").run([], result)
|
||||
report_mock.assert_called_once_with([], result)
|
||||
|
||||
@ -32,7 +32,7 @@ def test_report_console(configuration: Configuration, result: Result, mocker: Mo
|
||||
"""
|
||||
must generate console report
|
||||
"""
|
||||
report_mock = mocker.patch("ahriman.core.report.console.Console.generate")
|
||||
report_mock = mocker.patch("ahriman.core.report.Console.generate")
|
||||
Report.load("x86_64", configuration, "console").run([], result)
|
||||
report_mock.assert_called_once_with([], result)
|
||||
|
||||
@ -41,7 +41,7 @@ def test_report_email(configuration: Configuration, result: Result, mocker: Mock
|
||||
"""
|
||||
must generate email report
|
||||
"""
|
||||
report_mock = mocker.patch("ahriman.core.report.email.Email.generate")
|
||||
report_mock = mocker.patch("ahriman.core.report.Email.generate")
|
||||
Report.load("x86_64", configuration, "email").run([], result)
|
||||
report_mock.assert_called_once_with([], result)
|
||||
|
||||
@ -50,7 +50,7 @@ def test_report_html(configuration: Configuration, result: Result, mocker: Mocke
|
||||
"""
|
||||
must generate html report
|
||||
"""
|
||||
report_mock = mocker.patch("ahriman.core.report.html.HTML.generate")
|
||||
report_mock = mocker.patch("ahriman.core.report.HTML.generate")
|
||||
Report.load("x86_64", configuration, "html").run([], result)
|
||||
report_mock.assert_called_once_with([], result)
|
||||
|
||||
@ -59,6 +59,6 @@ def test_report_telegram(configuration: Configuration, result: Result, mocker: M
|
||||
"""
|
||||
must generate telegram report
|
||||
"""
|
||||
report_mock = mocker.patch("ahriman.core.report.telegram.Telegram.generate")
|
||||
report_mock = mocker.patch("ahriman.core.report.Telegram.generate")
|
||||
Report.load("x86_64", configuration, "telegram").run([], result)
|
||||
report_mock.assert_called_once_with([], result)
|
||||
|
@ -5,7 +5,7 @@ from pytest_mock import MockerFixture
|
||||
from unittest import mock
|
||||
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.report.telegram import Telegram
|
||||
from ahriman.core.report import Telegram
|
||||
from ahriman.models.package import Package
|
||||
from ahriman.models.result import Result
|
||||
|
||||
@ -50,7 +50,7 @@ def test_generate(configuration: Configuration, package_ahriman: Package, result
|
||||
"""
|
||||
must generate report
|
||||
"""
|
||||
send_mock = mocker.patch("ahriman.core.report.telegram.Telegram._send")
|
||||
send_mock = mocker.patch("ahriman.core.report.Telegram._send")
|
||||
|
||||
report = Telegram("x86_64", configuration, "telegram")
|
||||
report.generate([package_ahriman], result)
|
||||
@ -62,8 +62,8 @@ def test_generate_big_text(configuration: Configuration, package_ahriman: Packag
|
||||
"""
|
||||
must generate report with big text
|
||||
"""
|
||||
mocker.patch("ahriman.core.report.jinja_template.JinjaTemplate.make_html", return_value="a\n" * 4096)
|
||||
send_mock = mocker.patch("ahriman.core.report.telegram.Telegram._send")
|
||||
mocker.patch("ahriman.core.report.JinjaTemplate.make_html", return_value="a\n" * 4096)
|
||||
send_mock = mocker.patch("ahriman.core.report.Telegram._send")
|
||||
|
||||
report = Telegram("x86_64", configuration, "telegram")
|
||||
report.generate([package_ahriman], result)
|
||||
@ -76,7 +76,7 @@ def test_generate_no_empty(configuration: Configuration, package_ahriman: Packag
|
||||
"""
|
||||
must generate report
|
||||
"""
|
||||
send_mock = mocker.patch("ahriman.core.report.telegram.Telegram._send")
|
||||
send_mock = mocker.patch("ahriman.core.report.Telegram._send")
|
||||
|
||||
report = Telegram("x86_64", configuration, "telegram")
|
||||
report.generate([package_ahriman], Result())
|
||||
|
@ -3,7 +3,7 @@ import pytest
|
||||
from pytest_mock import MockerFixture
|
||||
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.database.sqlite import SQLite
|
||||
from ahriman.core.database import SQLite
|
||||
from ahriman.core.repository import Repository
|
||||
from ahriman.core.repository.cleaner import Cleaner
|
||||
from ahriman.core.repository.executor import Executor
|
||||
|
@ -72,6 +72,6 @@ def test_clear_queue(cleaner: Cleaner, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must clear queued packages from the database
|
||||
"""
|
||||
clear_mock = mocker.patch("ahriman.core.database.sqlite.SQLite.build_queue_clear")
|
||||
clear_mock = mocker.patch("ahriman.core.database.SQLite.build_queue_clear")
|
||||
cleaner.clear_queue()
|
||||
clear_mock.assert_called_once_with(None)
|
||||
|
@ -5,9 +5,9 @@ from pytest_mock import MockerFixture
|
||||
from unittest import mock
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from ahriman.core.report.report import Report
|
||||
from ahriman.core.report import Report
|
||||
from ahriman.core.repository.executor import Executor
|
||||
from ahriman.core.upload.upload import Upload
|
||||
from ahriman.core.upload import Upload
|
||||
from ahriman.models.package import Package
|
||||
|
||||
|
||||
@ -64,8 +64,8 @@ def test_process_remove_base(executor: Executor, package_ahriman: Package, mocke
|
||||
mocker.patch("ahriman.core.repository.executor.Executor.packages", return_value=[package_ahriman])
|
||||
tree_clear_mock = mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_clear")
|
||||
repo_remove_mock = mocker.patch("ahriman.core.alpm.repo.Repo.remove")
|
||||
build_queue_mock = mocker.patch("ahriman.core.database.sqlite.SQLite.build_queue_clear")
|
||||
patches_mock = mocker.patch("ahriman.core.database.sqlite.SQLite.patches_remove")
|
||||
build_queue_mock = mocker.patch("ahriman.core.database.SQLite.build_queue_clear")
|
||||
patches_mock = mocker.patch("ahriman.core.database.SQLite.patches_remove")
|
||||
status_client_mock = mocker.patch("ahriman.core.status.client.Client.remove")
|
||||
|
||||
executor.process_remove([package_ahriman.base])
|
||||
@ -150,8 +150,8 @@ def test_process_report(executor: Executor, package_ahriman: Package, mocker: Mo
|
||||
must process report
|
||||
"""
|
||||
mocker.patch("ahriman.core.repository.executor.Executor.packages", return_value=[package_ahriman])
|
||||
mocker.patch("ahriman.core.report.report.Report.load", return_value=Report("x86_64", executor.configuration))
|
||||
report_mock = mocker.patch("ahriman.core.report.report.Report.run")
|
||||
mocker.patch("ahriman.core.report.Report.load", return_value=Report("x86_64", executor.configuration))
|
||||
report_mock = mocker.patch("ahriman.core.report.Report.run")
|
||||
|
||||
executor.process_report(["dummy"], [])
|
||||
report_mock.assert_called_once_with([package_ahriman], [])
|
||||
@ -170,8 +170,8 @@ def test_process_upload(executor: Executor, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must process sync
|
||||
"""
|
||||
mocker.patch("ahriman.core.upload.upload.Upload.load", return_value=Upload("x86_64", executor.configuration))
|
||||
upload_mock = mocker.patch("ahriman.core.upload.upload.Upload.run")
|
||||
mocker.patch("ahriman.core.upload.Upload.load", return_value=Upload("x86_64", executor.configuration))
|
||||
upload_mock = mocker.patch("ahriman.core.upload.Upload.run")
|
||||
|
||||
executor.process_sync(["dummy"], [])
|
||||
upload_mock.assert_called_once_with(executor.paths.repository, [])
|
||||
|
@ -1,7 +1,7 @@
|
||||
from pytest_mock import MockerFixture
|
||||
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.database.sqlite import SQLite
|
||||
from ahriman.core.database import SQLite
|
||||
from ahriman.core.exceptions import UnsafeRun
|
||||
from ahriman.core.repository.repository_properties import RepositoryProperties
|
||||
from ahriman.core.status.web_client import WebClient
|
||||
|
@ -190,7 +190,7 @@ def test_updates_manual_status_known(update_handler: UpdateHandler, package_ahri
|
||||
"""
|
||||
must create record for known package via reporter
|
||||
"""
|
||||
mocker.patch("ahriman.core.database.sqlite.SQLite.build_queue_get", return_value=[package_ahriman])
|
||||
mocker.patch("ahriman.core.database.SQLite.build_queue_get", return_value=[package_ahriman])
|
||||
mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.packages", return_value=[package_ahriman])
|
||||
status_client_mock = mocker.patch("ahriman.core.status.client.Client.set_pending")
|
||||
|
||||
@ -203,7 +203,7 @@ def test_updates_manual_status_unknown(update_handler: UpdateHandler, package_ah
|
||||
"""
|
||||
must create record for unknown package via reporter
|
||||
"""
|
||||
mocker.patch("ahriman.core.database.sqlite.SQLite.build_queue_get", return_value=[package_ahriman])
|
||||
mocker.patch("ahriman.core.database.SQLite.build_queue_get", return_value=[package_ahriman])
|
||||
mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.packages", return_value=[])
|
||||
status_client_mock = mocker.patch("ahriman.core.status.client.Client.set_unknown")
|
||||
|
||||
@ -216,6 +216,6 @@ def test_updates_manual_with_failures(update_handler: UpdateHandler, package_ahr
|
||||
"""
|
||||
must process manual through the packages with failure
|
||||
"""
|
||||
mocker.patch("ahriman.core.database.sqlite.SQLite.build_queue_get", side_effect=Exception())
|
||||
mocker.patch("ahriman.core.database.SQLite.build_queue_get", side_effect=Exception())
|
||||
mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.packages", return_value=[package_ahriman])
|
||||
assert update_handler.updates_manual() == []
|
||||
|
@ -1,12 +1,9 @@
|
||||
import pytest
|
||||
import tempfile
|
||||
|
||||
from pathlib import Path
|
||||
from pytest_mock import MockerFixture
|
||||
from unittest.mock import PropertyMock
|
||||
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.database.sqlite import SQLite
|
||||
from ahriman.core.database import SQLite
|
||||
from ahriman.core.exceptions import UnknownPackage
|
||||
from ahriman.core.status.watcher import Watcher
|
||||
from ahriman.core.status.web_client import WebClient
|
||||
@ -51,7 +48,7 @@ def test_load(watcher: Watcher, package_ahriman: Package, mocker: MockerFixture)
|
||||
must correctly load packages
|
||||
"""
|
||||
mocker.patch("ahriman.core.repository.repository.Repository.packages", return_value=[package_ahriman])
|
||||
cache_mock = mocker.patch("ahriman.core.database.sqlite.SQLite.packages_get")
|
||||
cache_mock = mocker.patch("ahriman.core.database.SQLite.packages_get")
|
||||
|
||||
watcher.load()
|
||||
cache_mock.assert_called_once_with()
|
||||
@ -66,7 +63,7 @@ def test_load_known(watcher: Watcher, package_ahriman: Package, mocker: MockerFi
|
||||
"""
|
||||
status = BuildStatus(BuildStatusEnum.Success)
|
||||
mocker.patch("ahriman.core.repository.repository.Repository.packages", return_value=[package_ahriman])
|
||||
mocker.patch("ahriman.core.database.sqlite.SQLite.packages_get", return_value=[(package_ahriman, status)])
|
||||
mocker.patch("ahriman.core.database.SQLite.packages_get", return_value=[(package_ahriman, status)])
|
||||
watcher.known = {package_ahriman.base: (package_ahriman, status)}
|
||||
|
||||
watcher.load()
|
||||
@ -78,7 +75,7 @@ def test_remove(watcher: Watcher, package_ahriman: Package, mocker: MockerFixtur
|
||||
"""
|
||||
must remove package base
|
||||
"""
|
||||
cache_mock = mocker.patch("ahriman.core.database.sqlite.SQLite.package_remove")
|
||||
cache_mock = mocker.patch("ahriman.core.database.SQLite.package_remove")
|
||||
watcher.known = {package_ahriman.base: (package_ahriman, BuildStatus())}
|
||||
|
||||
watcher.remove(package_ahriman.base)
|
||||
@ -90,7 +87,7 @@ def test_remove_unknown(watcher: Watcher, package_ahriman: Package, mocker: Mock
|
||||
"""
|
||||
must not fail on unknown base removal
|
||||
"""
|
||||
cache_mock = mocker.patch("ahriman.core.database.sqlite.SQLite.package_remove")
|
||||
cache_mock = mocker.patch("ahriman.core.database.SQLite.package_remove")
|
||||
|
||||
watcher.remove(package_ahriman.base)
|
||||
cache_mock.assert_called_once_with(package_ahriman.base)
|
||||
@ -100,7 +97,7 @@ def test_update(watcher: Watcher, package_ahriman: Package, mocker: MockerFixtur
|
||||
"""
|
||||
must update package status
|
||||
"""
|
||||
cache_mock = mocker.patch("ahriman.core.database.sqlite.SQLite.package_update")
|
||||
cache_mock = mocker.patch("ahriman.core.database.SQLite.package_update")
|
||||
|
||||
watcher.update(package_ahriman.base, BuildStatusEnum.Unknown, package_ahriman)
|
||||
cache_mock.assert_called_once_with(package_ahriman, pytest.helpers.anyvar(int))
|
||||
@ -113,7 +110,7 @@ def test_update_ping(watcher: Watcher, package_ahriman: Package, mocker: MockerF
|
||||
"""
|
||||
must update package status only for known package
|
||||
"""
|
||||
cache_mock = mocker.patch("ahriman.core.database.sqlite.SQLite.package_update")
|
||||
cache_mock = mocker.patch("ahriman.core.database.SQLite.package_update")
|
||||
watcher.known = {package_ahriman.base: (package_ahriman, BuildStatus())}
|
||||
|
||||
watcher.update(package_ahriman.base, BuildStatusEnum.Success, None)
|
||||
|
@ -2,7 +2,7 @@ import pytest
|
||||
|
||||
from pytest_mock import MockerFixture
|
||||
|
||||
from ahriman.core.database.sqlite import SQLite
|
||||
from ahriman.core.database import SQLite
|
||||
from ahriman.core.tree import Leaf, Tree
|
||||
from ahriman.models.package import Package
|
||||
|
||||
|
@ -5,9 +5,7 @@ from typing import Any, Dict, List
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.upload.github import Github
|
||||
from ahriman.core.upload.rsync import Rsync
|
||||
from ahriman.core.upload.s3 import S3
|
||||
from ahriman.core.upload import Github, Rsync, S3
|
||||
|
||||
|
||||
_s3_object = namedtuple("s3_object", ["key", "e_tag", "delete"])
|
||||
|
@ -6,14 +6,14 @@ from pytest_mock import MockerFixture
|
||||
from typing import Any, Dict
|
||||
from unittest import mock
|
||||
|
||||
from ahriman.core.upload.github import Github
|
||||
from ahriman.core.upload import Github
|
||||
|
||||
|
||||
def test_asset_remove(github: Github, github_release: Dict[str, Any], mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must remove asset from the release
|
||||
"""
|
||||
request_mock = mocker.patch("ahriman.core.upload.github.Github._request")
|
||||
request_mock = mocker.patch("ahriman.core.upload.Github._request")
|
||||
github.asset_remove(github_release, "asset_name")
|
||||
request_mock.assert_called_once_with("DELETE", "asset_url")
|
||||
|
||||
@ -22,7 +22,7 @@ def test_asset_remove_unknown(github: Github, github_release: Dict[str, Any], mo
|
||||
"""
|
||||
must not fail if no asset found
|
||||
"""
|
||||
request_mock = mocker.patch("ahriman.core.upload.github.Github._request")
|
||||
request_mock = mocker.patch("ahriman.core.upload.Github._request")
|
||||
github.asset_remove(github_release, "unknown_asset_name")
|
||||
request_mock.assert_not_called()
|
||||
|
||||
@ -32,8 +32,8 @@ def test_asset_upload(github: Github, github_release: Dict[str, Any], mocker: Mo
|
||||
must upload asset to the repository
|
||||
"""
|
||||
mocker.patch("pathlib.Path.open", return_value=b"")
|
||||
request_mock = mocker.patch("ahriman.core.upload.github.Github._request")
|
||||
remove_mock = mocker.patch("ahriman.core.upload.github.Github.asset_remove")
|
||||
request_mock = mocker.patch("ahriman.core.upload.Github._request")
|
||||
remove_mock = mocker.patch("ahriman.core.upload.Github.asset_remove")
|
||||
|
||||
github.asset_upload(github_release, Path("/root/new.tar.xz"))
|
||||
request_mock.assert_called_once_with("POST", "upload_url", params={"name": "new.tar.xz"},
|
||||
@ -46,8 +46,8 @@ def test_asset_upload_with_removal(github: Github, github_release: Dict[str, Any
|
||||
must remove existing file before upload
|
||||
"""
|
||||
mocker.patch("pathlib.Path.open", return_value=b"")
|
||||
mocker.patch("ahriman.core.upload.github.Github._request")
|
||||
remove_mock = mocker.patch("ahriman.core.upload.github.Github.asset_remove")
|
||||
mocker.patch("ahriman.core.upload.Github._request")
|
||||
remove_mock = mocker.patch("ahriman.core.upload.Github.asset_remove")
|
||||
|
||||
github.asset_upload(github_release, Path("asset_name"))
|
||||
github.asset_upload(github_release, Path("/root/asset_name"))
|
||||
@ -62,9 +62,9 @@ def test_asset_upload_empty_mimetype(github: Github, github_release: Dict[str, A
|
||||
must upload asset to the repository with empty mime type if cannot guess it
|
||||
"""
|
||||
mocker.patch("pathlib.Path.open", return_value=b"")
|
||||
mocker.patch("ahriman.core.upload.github.Github.asset_remove")
|
||||
mocker.patch("ahriman.core.upload.Github.asset_remove")
|
||||
mocker.patch("mimetypes.guess_type", return_value=(None, None))
|
||||
request_mock = mocker.patch("ahriman.core.upload.github.Github._request")
|
||||
request_mock = mocker.patch("ahriman.core.upload.Github._request")
|
||||
|
||||
github.asset_upload(github_release, Path("/root/new.tar.xz"))
|
||||
request_mock.assert_called_once_with("POST", "upload_url", params={"name": "new.tar.xz"},
|
||||
@ -84,7 +84,7 @@ def test_files_remove(github: Github, github_release: Dict[str, Any], mocker: Mo
|
||||
"""
|
||||
must remove files from the remote
|
||||
"""
|
||||
remove_mock = mocker.patch("ahriman.core.upload.github.Github.asset_remove")
|
||||
remove_mock = mocker.patch("ahriman.core.upload.Github.asset_remove")
|
||||
github.files_remove(github_release, {Path("a"): "a"}, {"a": "a", "b": "b"})
|
||||
remove_mock.assert_called_once_with(github_release, "b")
|
||||
|
||||
@ -93,7 +93,7 @@ def test_files_remove_empty(github: Github, github_release: Dict[str, Any], mock
|
||||
"""
|
||||
must remove nothing if nothing changed
|
||||
"""
|
||||
remove_mock = mocker.patch("ahriman.core.upload.github.Github.asset_remove")
|
||||
remove_mock = mocker.patch("ahriman.core.upload.Github.asset_remove")
|
||||
github.files_remove(github_release, {Path("a"): "a"}, {"a": "a"})
|
||||
remove_mock.assert_not_called()
|
||||
|
||||
@ -102,7 +102,7 @@ def test_files_upload(github: Github, github_release: Dict[str, Any], mocker: Mo
|
||||
"""
|
||||
must upload files to the remote
|
||||
"""
|
||||
upload_mock = mocker.patch("ahriman.core.upload.github.Github.asset_upload")
|
||||
upload_mock = mocker.patch("ahriman.core.upload.Github.asset_upload")
|
||||
github.files_upload(github_release, {Path("a"): "a", Path("b"): "c", Path("c"): "c"}, {"a": "a", "b": "b"})
|
||||
upload_mock.assert_has_calls([
|
||||
mock.call(github_release, Path("b")),
|
||||
@ -114,7 +114,7 @@ def test_files_upload_empty(github: Github, github_release: Dict[str, Any], mock
|
||||
"""
|
||||
must upload nothing if nothing changed
|
||||
"""
|
||||
upload_mock = mocker.patch("ahriman.core.upload.github.Github.asset_upload")
|
||||
upload_mock = mocker.patch("ahriman.core.upload.Github.asset_upload")
|
||||
github.files_upload(github_release, {Path("a"): "a"}, {"a": "a"})
|
||||
upload_mock.assert_not_called()
|
||||
|
||||
@ -123,7 +123,7 @@ def test_release_create(github: Github, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must create release
|
||||
"""
|
||||
request_mock = mocker.patch("ahriman.core.upload.github.Github._request")
|
||||
request_mock = mocker.patch("ahriman.core.upload.Github._request")
|
||||
github.release_create()
|
||||
request_mock.assert_called_once_with("POST", pytest.helpers.anyvar(str, True),
|
||||
json={"tag_name": github.architecture, "name": github.architecture})
|
||||
@ -133,7 +133,7 @@ def test_release_get(github: Github, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must get release
|
||||
"""
|
||||
request_mock = mocker.patch("ahriman.core.upload.github.Github._request")
|
||||
request_mock = mocker.patch("ahriman.core.upload.Github._request")
|
||||
github.release_get()
|
||||
request_mock.assert_called_once_with("GET", pytest.helpers.anyvar(str, True))
|
||||
|
||||
@ -144,7 +144,7 @@ def test_release_get_empty(github: Github, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
response = requests.Response()
|
||||
response.status_code = 404
|
||||
mocker.patch("ahriman.core.upload.github.Github._request", side_effect=requests.HTTPError(response=response))
|
||||
mocker.patch("ahriman.core.upload.Github._request", side_effect=requests.HTTPError(response=response))
|
||||
assert github.release_get() is None
|
||||
|
||||
|
||||
@ -152,7 +152,7 @@ def test_release_get_exception(github: Github, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must re-raise non HTTPError exception
|
||||
"""
|
||||
mocker.patch("ahriman.core.upload.github.Github._request", side_effect=Exception())
|
||||
mocker.patch("ahriman.core.upload.Github._request", side_effect=Exception())
|
||||
with pytest.raises(Exception):
|
||||
github.release_get()
|
||||
|
||||
@ -162,7 +162,7 @@ def test_release_get_exception_http_error(github: Github, mocker: MockerFixture)
|
||||
must re-raise HTTPError exception with code differs from 404
|
||||
"""
|
||||
exception = requests.HTTPError(response=requests.Response())
|
||||
mocker.patch("ahriman.core.upload.github.Github._request", side_effect=exception)
|
||||
mocker.patch("ahriman.core.upload.Github._request", side_effect=exception)
|
||||
with pytest.raises(requests.HTTPError):
|
||||
github.release_get()
|
||||
|
||||
@ -171,7 +171,7 @@ def test_release_update(github: Github, github_release: Dict[str, Any], mocker:
|
||||
"""
|
||||
must update release
|
||||
"""
|
||||
request_mock = mocker.patch("ahriman.core.upload.github.Github._request")
|
||||
request_mock = mocker.patch("ahriman.core.upload.Github._request")
|
||||
github.release_update(github_release, "body")
|
||||
request_mock.assert_called_once_with("POST", "release_url", json={"body": "body"})
|
||||
|
||||
@ -180,12 +180,12 @@ def test_release_sync(github: Github, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must run sync command
|
||||
"""
|
||||
release_get_mock = mocker.patch("ahriman.core.upload.github.Github.release_get", return_value={})
|
||||
get_hashes_mock = mocker.patch("ahriman.core.upload.github.Github.get_hashes", return_value={})
|
||||
get_local_files_mock = mocker.patch("ahriman.core.upload.github.Github.get_local_files", return_value={})
|
||||
files_upload_mock = mocker.patch("ahriman.core.upload.github.Github.files_upload")
|
||||
files_remove_mock = mocker.patch("ahriman.core.upload.github.Github.files_remove")
|
||||
release_update_mock = mocker.patch("ahriman.core.upload.github.Github.release_update")
|
||||
release_get_mock = mocker.patch("ahriman.core.upload.Github.release_get", return_value={})
|
||||
get_hashes_mock = mocker.patch("ahriman.core.upload.Github.get_hashes", return_value={})
|
||||
get_local_files_mock = mocker.patch("ahriman.core.upload.Github.get_local_files", return_value={})
|
||||
files_upload_mock = mocker.patch("ahriman.core.upload.Github.files_upload")
|
||||
files_remove_mock = mocker.patch("ahriman.core.upload.Github.files_remove")
|
||||
release_update_mock = mocker.patch("ahriman.core.upload.Github.release_update")
|
||||
|
||||
github.sync(Path("local"), [])
|
||||
release_get_mock.assert_called_once_with()
|
||||
@ -200,13 +200,13 @@ def test_release_sync_create_release(github: Github, mocker: MockerFixture) -> N
|
||||
"""
|
||||
must create release in case if it does not exist
|
||||
"""
|
||||
mocker.patch("ahriman.core.upload.github.Github.release_get", return_value=None)
|
||||
mocker.patch("ahriman.core.upload.github.Github.get_hashes")
|
||||
mocker.patch("ahriman.core.upload.github.Github.get_local_files")
|
||||
mocker.patch("ahriman.core.upload.github.Github.files_upload")
|
||||
mocker.patch("ahriman.core.upload.github.Github.files_remove")
|
||||
mocker.patch("ahriman.core.upload.github.Github.release_update")
|
||||
release_create_mock = mocker.patch("ahriman.core.upload.github.Github.release_create")
|
||||
mocker.patch("ahriman.core.upload.Github.release_get", return_value=None)
|
||||
mocker.patch("ahriman.core.upload.Github.get_hashes")
|
||||
mocker.patch("ahriman.core.upload.Github.get_local_files")
|
||||
mocker.patch("ahriman.core.upload.Github.files_upload")
|
||||
mocker.patch("ahriman.core.upload.Github.files_remove")
|
||||
mocker.patch("ahriman.core.upload.Github.release_update")
|
||||
release_create_mock = mocker.patch("ahriman.core.upload.Github.release_create")
|
||||
|
||||
github.sync(Path("local"), [])
|
||||
release_create_mock.assert_called_once_with()
|
||||
|
@ -5,8 +5,7 @@ from pathlib import Path
|
||||
from pytest_mock import MockerFixture
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from ahriman.core.upload.github import Github
|
||||
from ahriman.core.upload.http_upload import HttpUpload
|
||||
from ahriman.core.upload import Github, HttpUpload
|
||||
|
||||
|
||||
def test_calculate_hash_empty(resource_path_root: Path) -> None:
|
||||
|
@ -1,13 +1,13 @@
|
||||
from pathlib import Path
|
||||
from pytest_mock import MockerFixture
|
||||
|
||||
from ahriman.core.upload.rsync import Rsync
|
||||
from ahriman.core.upload import Rsync
|
||||
|
||||
|
||||
def test_sync(rsync: Rsync, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must run sync command
|
||||
"""
|
||||
check_output_mock = mocker.patch("ahriman.core.upload.rsync.Rsync._check_output")
|
||||
check_output_mock = mocker.patch("ahriman.core.upload.Rsync._check_output")
|
||||
rsync.sync(Path("path"), [])
|
||||
check_output_mock.assert_called_once_with(*rsync.command, "path", rsync.remote, exception=None, logger=rsync.logger)
|
||||
|
@ -1,12 +1,10 @@
|
||||
import pytest
|
||||
|
||||
from pathlib import Path
|
||||
from pytest_mock import MockerFixture
|
||||
from typing import Any, List, Optional, Tuple
|
||||
from unittest import mock
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from ahriman.core.upload.s3 import S3
|
||||
from ahriman.core.upload import S3
|
||||
|
||||
|
||||
_chunk_size = 8 * 1024 * 1024
|
||||
@ -106,10 +104,10 @@ def test_sync(s3: S3, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must run sync command
|
||||
"""
|
||||
local_files_mock = mocker.patch("ahriman.core.upload.s3.S3.get_local_files", return_value=["a"])
|
||||
remote_objects_mock = mocker.patch("ahriman.core.upload.s3.S3.get_remote_objects", return_value=["b"])
|
||||
remove_files_mock = mocker.patch("ahriman.core.upload.s3.S3.files_remove")
|
||||
upload_files_mock = mocker.patch("ahriman.core.upload.s3.S3.files_upload")
|
||||
local_files_mock = mocker.patch("ahriman.core.upload.S3.get_local_files", return_value=["a"])
|
||||
remote_objects_mock = mocker.patch("ahriman.core.upload.S3.get_remote_objects", return_value=["b"])
|
||||
remove_files_mock = mocker.patch("ahriman.core.upload.S3.files_remove")
|
||||
upload_files_mock = mocker.patch("ahriman.core.upload.S3.files_upload")
|
||||
|
||||
s3.sync(Path("root"), [])
|
||||
remote_objects_mock.assert_called_once_with()
|
||||
|
@ -5,7 +5,7 @@ from pytest_mock import MockerFixture
|
||||
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.exceptions import SyncFailed
|
||||
from ahriman.core.upload.upload import Upload
|
||||
from ahriman.core.upload import Upload
|
||||
from ahriman.models.upload_settings import UploadSettings
|
||||
|
||||
|
||||
@ -13,7 +13,7 @@ def test_upload_failure(configuration: Configuration, mocker: MockerFixture) ->
|
||||
"""
|
||||
must raise SyncFailed on errors
|
||||
"""
|
||||
mocker.patch("ahriman.core.upload.rsync.Rsync.sync", side_effect=Exception())
|
||||
mocker.patch("ahriman.core.upload.Rsync.sync", side_effect=Exception())
|
||||
with pytest.raises(SyncFailed):
|
||||
Upload.load("x86_64", configuration, "rsync").run(Path("path"), [])
|
||||
|
||||
@ -23,7 +23,7 @@ def test_report_dummy(configuration: Configuration, mocker: MockerFixture) -> No
|
||||
must construct dummy upload class
|
||||
"""
|
||||
mocker.patch("ahriman.models.upload_settings.UploadSettings.from_option", return_value=UploadSettings.Disabled)
|
||||
upload_mock = mocker.patch("ahriman.core.upload.upload.Upload.sync")
|
||||
upload_mock = mocker.patch("ahriman.core.upload.Upload.sync")
|
||||
Upload.load("x86_64", configuration, "disabled").run(Path("path"), [])
|
||||
upload_mock.assert_called_once_with(Path("path"), [])
|
||||
|
||||
@ -32,7 +32,7 @@ def test_upload_rsync(configuration: Configuration, mocker: MockerFixture) -> No
|
||||
"""
|
||||
must upload via rsync
|
||||
"""
|
||||
upload_mock = mocker.patch("ahriman.core.upload.rsync.Rsync.sync")
|
||||
upload_mock = mocker.patch("ahriman.core.upload.Rsync.sync")
|
||||
Upload.load("x86_64", configuration, "rsync").run(Path("path"), [])
|
||||
upload_mock.assert_called_once_with(Path("path"), [])
|
||||
|
||||
@ -41,7 +41,7 @@ def test_upload_s3(configuration: Configuration, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must upload via s3
|
||||
"""
|
||||
upload_mock = mocker.patch("ahriman.core.upload.s3.S3.sync")
|
||||
upload_mock = mocker.patch("ahriman.core.upload.S3.sync")
|
||||
Upload.load("x86_64", configuration, "customs3").run(Path("path"), [])
|
||||
upload_mock.assert_called_once_with(Path("path"), [])
|
||||
|
||||
@ -50,6 +50,6 @@ def test_upload_github(configuration: Configuration, mocker: MockerFixture) -> N
|
||||
"""
|
||||
must upload via github
|
||||
"""
|
||||
upload_mock = mocker.patch("ahriman.core.upload.github.Github.sync")
|
||||
upload_mock = mocker.patch("ahriman.core.upload.Github.sync")
|
||||
Upload.load("x86_64", configuration, "github").run(Path("path"), [])
|
||||
upload_mock.assert_called_once_with(Path("path"), [])
|
||||
|
Reference in New Issue
Block a user