diff --git a/debian/rules b/debian/rules index 1f0e5ea..e13437b 100755 --- a/debian/rules +++ b/debian/rules @@ -1,7 +1,7 @@ #!/usr/bin/make -f # -*- makefile -*- -export PYBUILD_NAME=xivo +export PYBUILD_NAME=wazo export PYBUILD_DESTDIR_python3=debian/xivo-lib-python-python3/ export PYBUILD_DISABLE=test diff --git a/integration_tests/assets/bin/myservice.py b/integration_tests/assets/bin/myservice.py index 3431965..019f996 100755 --- a/integration_tests/assets/bin/myservice.py +++ b/integration_tests/assets/bin/myservice.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# Copyright 2016-2023 The Wazo Authors (see the AUTHORS file) +# Copyright 2016-2024 The Wazo Authors (see the AUTHORS file) # SPDX-License-Identifier: GPL-3.0-or-later from __future__ import annotations @@ -13,7 +13,7 @@ import requests from flask import Flask, Response, jsonify -from xivo.consul_helpers import ServiceCatalogRegistration +from wazo.consul_helpers import ServiceCatalogRegistration UUID = 'foobar' diff --git a/integration_tests/assets/bin/thread-exception.py b/integration_tests/assets/bin/thread-exception.py index eca6af1..d4225e8 100644 --- a/integration_tests/assets/bin/thread-exception.py +++ b/integration_tests/assets/bin/thread-exception.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# Copyright 2018-2023 The Wazo Authors (see the AUTHORS file) +# Copyright 2018-2024 The Wazo Authors (see the AUTHORS file) # SPDX-License-Identifier: GPL-3.0-or-later from __future__ import annotations @@ -7,7 +7,7 @@ import time from typing import NoReturn -from xivo import xivo_logging +from wazo import xivo_logging xivo_logging.setup_logging('/dev/null') diff --git a/setup.cfg b/setup.cfg index e90da61..94d023b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,2 +1,2 @@ [tool:pytest] -testpaths=xivo +testpaths=wazo diff --git a/setup.py b/setup.py index a25506b..cab7efd 100755 --- a/setup.py +++ b/setup.py @@ -1,13 +1,13 @@ #!/usr/bin/env python3 -# Copyright 2007-2023 The Wazo Authors (see the AUTHORS file) +# Copyright 2007-2024 The Wazo Authors (see the AUTHORS file) # SPDX-License-Identifier: GPL-3.0-or-later from setuptools import find_packages, setup setup( - name='xivo', + name='wazo', version='1.0', - description='These are useful python libraries to be used with XIVO code', + description='These are useful python libraries to be used with Wazo code', author='Wazo Authors', author_email='dev@wazo.community', url='http://wazo.community', diff --git a/tox.ini b/tox.ini index 1c85016..16b1379 100644 --- a/tox.ini +++ b/tox.ini @@ -8,7 +8,7 @@ envlist = py39, linters [testenv] commands = - pytest --junitxml=unit-tests.xml --cov=xivo --cov-report term --cov-report xml:coverage.xml xivo {posargs} + pytest --junitxml=unit-tests.xml --cov=wazo --cov-report term --cov-report xml:coverage.xml wazo {posargs} deps = -rrequirements.txt -rtest-requirements.txt diff --git a/wazo/agitb.py b/wazo/agitb.py index 2ece48b..6e0cc8c 100644 --- a/wazo/agitb.py +++ b/wazo/agitb.py @@ -1,4 +1,4 @@ -# Copyright 2013-2023 The Wazo Authors (see the AUTHORS file) +# Copyright 2013-2024 The Wazo Authors (see the AUTHORS file) # SPDX-License-Identifier: GPL-3.0-or-later """More comprehensive traceback formatting for AGI in Python. @@ -53,7 +53,7 @@ from typing import TYPE_CHECKING, Any, Callable, NamedTuple, NewType, TextIO if TYPE_CHECKING: - from xivo.agi import AGI + from wazo.agi import AGI Undefined = NewType('Undefined', list[str]) diff --git a/wazo/cli/command/exit.py b/wazo/cli/command/exit.py index 953aac7..e62e1e5 100644 --- a/wazo/cli/command/exit.py +++ b/wazo/cli/command/exit.py @@ -1,10 +1,10 @@ -# Copyright 2013-2023 The Wazo Authors (see the AUTHORS file) +# Copyright 2013-2024 The Wazo Authors (see the AUTHORS file) # SPDX-License-Identifier: GPL-3.0-or-later from __future__ import annotations from typing import NoReturn -from xivo.cli.command.base import BaseCommand +from wazo.cli.command.base import BaseCommand class ExitCommand(BaseCommand): diff --git a/wazo/cli/command/help.py b/wazo/cli/command/help.py index 7eab380..78d0107 100644 --- a/wazo/cli/command/help.py +++ b/wazo/cli/command/help.py @@ -1,12 +1,12 @@ -# Copyright 2013-2023 The Wazo Authors (see the AUTHORS file) +# Copyright 2013-2024 The Wazo Authors (see the AUTHORS file) # SPDX-License-Identifier: GPL-3.0-or-later from __future__ import annotations from operator import attrgetter from typing import TYPE_CHECKING -from xivo.cli.command.base import BaseCommand -from xivo.cli.exception import NoMatchingCommandError +from wazo.cli.command.base import BaseCommand +from wazo.cli.exception import NoMatchingCommandError if TYPE_CHECKING: from ..registry import CommandRegistry diff --git a/wazo/cli/command/unknown.py b/wazo/cli/command/unknown.py index 26a0f67..2758430 100644 --- a/wazo/cli/command/unknown.py +++ b/wazo/cli/command/unknown.py @@ -1,10 +1,10 @@ -# Copyright 2017-2023 The Wazo Authors (see the AUTHORS file) +# Copyright 2017-2024 The Wazo Authors (see the AUTHORS file) # SPDX-License-Identifier: GPL-3.0-or-later from __future__ import annotations from typing import NoReturn -from xivo.cli.command.base import BaseCommand +from wazo.cli.command.base import BaseCommand class _BaseUnknownCommand(BaseCommand): diff --git a/wazo/cli/completion/tests/test_completer.py b/wazo/cli/completion/tests/test_completer.py index 273f0eb..076f79e 100644 --- a/wazo/cli/completion/tests/test_completer.py +++ b/wazo/cli/completion/tests/test_completer.py @@ -1,4 +1,4 @@ -# Copyright 2013-2023 The Wazo Authors (see the AUTHORS file) +# Copyright 2013-2024 The Wazo Authors (see the AUTHORS file) # SPDX-License-Identifier: GPL-3.0-or-later from __future__ import annotations @@ -6,8 +6,9 @@ from unittest.mock import Mock from hamcrest import assert_that, equal_to -from xivo.cli.completion.completer import CommandLineCompleter -from xivo.cli.registry import CommandRegistry + +from wazo.cli.completion.completer import CommandLineCompleter +from wazo.cli.registry import CommandRegistry class TestCompleter(unittest.TestCase): diff --git a/wazo/cli/executor.py b/wazo/cli/executor.py index 7d61eb3..7ab89d4 100644 --- a/wazo/cli/executor.py +++ b/wazo/cli/executor.py @@ -1,11 +1,11 @@ -# Copyright 2013-2023 The Wazo Authors (see the AUTHORS file) +# Copyright 2013-2024 The Wazo Authors (see the AUTHORS file) # SPDX-License-Identifier: GPL-3.0-or-later from __future__ import annotations from collections.abc import Iterable from typing import TYPE_CHECKING -from xivo.cli.exception import UsageError +from wazo.cli.exception import UsageError if TYPE_CHECKING: from .command.base import BaseCommand diff --git a/wazo/cli/facade.py b/wazo/cli/facade.py index 5818d58..98ba305 100644 --- a/wazo/cli/facade.py +++ b/wazo/cli/facade.py @@ -1,4 +1,4 @@ -# Copyright 2013-2023 The Wazo Authors (see the AUTHORS file) +# Copyright 2013-2024 The Wazo Authors (see the AUTHORS file) # SPDX-License-Identifier: GPL-3.0-or-later from __future__ import annotations @@ -6,17 +6,17 @@ import sys from typing import TYPE_CHECKING -from xivo.cli import history -from xivo.cli.command.exit import ExitCommand -from xivo.cli.command.help import HelpCommand -from xivo.cli.command.unknown import PrintingUnknownCommand, _BaseUnknownCommand -from xivo.cli.completion.completer import CommandLineCompleter -from xivo.cli.completion.readline import ReadlineCompletionHelper -from xivo.cli.errorhandler import PrintTracebackErrorHandler, ReRaiseErrorHandler -from xivo.cli.executor import Executor -from xivo.cli.parser import RawCommandLineParser -from xivo.cli.registry import CommandRegistry -from xivo.cli.source.input import InputRawCommandLineSource +from wazo.cli import history +from wazo.cli.command.exit import ExitCommand +from wazo.cli.command.help import HelpCommand +from wazo.cli.command.unknown import PrintingUnknownCommand, _BaseUnknownCommand +from wazo.cli.completion.completer import CommandLineCompleter +from wazo.cli.completion.readline import ReadlineCompletionHelper +from wazo.cli.errorhandler import PrintTracebackErrorHandler, ReRaiseErrorHandler +from wazo.cli.executor import Executor +from wazo.cli.parser import RawCommandLineParser +from wazo.cli.registry import CommandRegistry +from wazo.cli.source.input import InputRawCommandLineSource if TYPE_CHECKING: from .command.base import BaseCommand diff --git a/wazo/cli/parser.py b/wazo/cli/parser.py index 713bcd5..5919ffe 100644 --- a/wazo/cli/parser.py +++ b/wazo/cli/parser.py @@ -1,11 +1,11 @@ -# Copyright 2013-2023 The Wazo Authors (see the AUTHORS file) +# Copyright 2013-2024 The Wazo Authors (see the AUTHORS file) # SPDX-License-Identifier: GPL-3.0-or-later from __future__ import annotations from typing import TYPE_CHECKING -from xivo.cli.commandline import CommandLine -from xivo.cli.exception import NoMatchingCommandError +from wazo.cli.commandline import CommandLine +from wazo.cli.exception import NoMatchingCommandError if TYPE_CHECKING: from .registry import CommandRegistry diff --git a/wazo/cli/registry.py b/wazo/cli/registry.py index ac235b0..9532b23 100644 --- a/wazo/cli/registry.py +++ b/wazo/cli/registry.py @@ -1,11 +1,11 @@ -# Copyright 2013-2023 The Wazo Authors (see the AUTHORS file) +# Copyright 2013-2024 The Wazo Authors (see the AUTHORS file) # SPDX-License-Identifier: GPL-3.0-or-later from __future__ import annotations from collections.abc import Sequence from typing import TYPE_CHECKING, Any -from xivo.cli.exception import CommandAlreadyRegisteredError, NoMatchingCommandError +from wazo.cli.exception import CommandAlreadyRegisteredError, NoMatchingCommandError if TYPE_CHECKING: from .command.base import BaseCommand diff --git a/wazo/cli/tests/test_parser.py b/wazo/cli/tests/test_parser.py index 1c2ac8a..f4d543c 100644 --- a/wazo/cli/tests/test_parser.py +++ b/wazo/cli/tests/test_parser.py @@ -1,4 +1,4 @@ -# Copyright 2013-2023 The Wazo Authors (see the AUTHORS file) +# Copyright 2013-2024 The Wazo Authors (see the AUTHORS file) # SPDX-License-Identifier: GPL-3.0-or-later @@ -6,9 +6,10 @@ from unittest.mock import Mock from hamcrest import assert_that, equal_to, none -from xivo.cli.exception import NoMatchingCommandError -from xivo.cli.parser import RawCommandLineParser -from xivo.cli.registry import CommandRegistry + +from wazo.cli.exception import NoMatchingCommandError +from wazo.cli.parser import RawCommandLineParser +from wazo.cli.registry import CommandRegistry class TestRawCommandLineParser(unittest.TestCase): diff --git a/wazo/cli/tests/test_registry.py b/wazo/cli/tests/test_registry.py index 39a09eb..d1efe84 100644 --- a/wazo/cli/tests/test_registry.py +++ b/wazo/cli/tests/test_registry.py @@ -1,4 +1,4 @@ -# Copyright 2013-2023 The Wazo Authors (see the AUTHORS file) +# Copyright 2013-2024 The Wazo Authors (see the AUTHORS file) # SPDX-License-Identifier: GPL-3.0-or-later @@ -6,8 +6,9 @@ from unittest.mock import Mock from hamcrest import assert_that, contains_inanyorder, equal_to -from xivo.cli.exception import CommandAlreadyRegisteredError, NoMatchingCommandError -from xivo.cli.registry import CommandRegistry + +from wazo.cli.exception import CommandAlreadyRegisteredError, NoMatchingCommandError +from wazo.cli.registry import CommandRegistry class TestCommandRegistry(unittest.TestCase): diff --git a/wazo/cli/tests/test_utils.py b/wazo/cli/tests/test_utils.py index 67b57d9..2669b8e 100644 --- a/wazo/cli/tests/test_utils.py +++ b/wazo/cli/tests/test_utils.py @@ -1,10 +1,10 @@ -# Copyright 2013-2023 The Wazo Authors (see the AUTHORS file) +# Copyright 2013-2024 The Wazo Authors (see the AUTHORS file) # SPDX-License-Identifier: GPL-3.0-or-later import unittest -from xivo.cli.utils import compute_ids +from wazo.cli.utils import compute_ids class TestComputeIDs(unittest.TestCase): diff --git a/wazo/cli/utils.py b/wazo/cli/utils.py index d141628..f43cd24 100644 --- a/wazo/cli/utils.py +++ b/wazo/cli/utils.py @@ -1,11 +1,11 @@ -# Copyright 2013-2023 The Wazo Authors (see the AUTHORS file) +# Copyright 2013-2024 The Wazo Authors (see the AUTHORS file) # SPDX-License-Identifier: GPL-3.0-or-later from __future__ import annotations import functools from typing import Any, Callable, TypeVar -from xivo.cli.exception import UsageError +from wazo.cli.exception import UsageError R = TypeVar('R') diff --git a/wazo/flask/tests/test_auth_verifier.py b/wazo/flask/tests/test_auth_verifier.py index 099723a..c7ff2e7 100644 --- a/wazo/flask/tests/test_auth_verifier.py +++ b/wazo/flask/tests/test_auth_verifier.py @@ -6,8 +6,9 @@ from unittest.mock import sentinel as s import pytest -from xivo.auth_verifier import Unauthorized, no_auth, required_acl, required_tenant -from xivo.http_exceptions import InvalidTokenAPIException + +from wazo.auth_verifier import Unauthorized, no_auth, required_acl, required_tenant +from wazo.http_exceptions import InvalidTokenAPIException from ..auth_verifier import AuthVerifierFlask @@ -32,11 +33,11 @@ def decorated(): return s.result with patch( - 'xivo.flask.auth_verifier.extract_tenant_id_from_header', + 'wazo.flask.auth_verifier.extract_tenant_id_from_header', tenant_extractor, ): - with patch('xivo.flask.auth_verifier.g', mock_g): - with patch('xivo.tenant_flask_helpers.g', mock_g): + with patch('wazo.flask.auth_verifier.g', mock_g): + with patch('wazo.tenant_flask_helpers.g', mock_g): result = decorated() assert result == s.result @@ -70,8 +71,8 @@ def test_verify_tenant_decorator(self): def decorated(): return s.result - with patch('xivo.flask.auth_verifier.g', mock_g): - with patch('xivo.tenant_flask_helpers.g', mock_g): + with patch('wazo.flask.auth_verifier.g', mock_g): + with patch('wazo.tenant_flask_helpers.g', mock_g): result = decorated() assert result == s.result @@ -107,8 +108,8 @@ def test_verify_tenant_when_invalid_token(self): def decorated(): return s.result - with patch('xivo.flask.auth_verifier.g', mock_g): - with patch('xivo.tenant_flask_helpers.g', mock_g): + with patch('wazo.flask.auth_verifier.g', mock_g): + with patch('wazo.tenant_flask_helpers.g', mock_g): with pytest.raises(Unauthorized) as exc_info: decorated() diff --git a/wazo/http_exceptions.py b/wazo/http_exceptions.py index d4eeea5..58e2c8b 100644 --- a/wazo/http_exceptions.py +++ b/wazo/http_exceptions.py @@ -3,7 +3,8 @@ from __future__ import annotations import requests -from xivo import rest_api_helpers + +from wazo import rest_api_helpers class Unauthorized(rest_api_helpers.APIException): diff --git a/wazo/tenant_flask_helpers.py b/wazo/tenant_flask_helpers.py index 49753d6..63c2da6 100644 --- a/wazo/tenant_flask_helpers.py +++ b/wazo/tenant_flask_helpers.py @@ -8,7 +8,8 @@ from flask import current_app, g from wazo_auth_client import Client as AuthClient from werkzeug.local import LocalProxy -from xivo.tenant_helpers import Token, User + +from wazo.tenant_helpers import Token, User from . import tenant_helpers diff --git a/wazo/tenant_helpers.py b/wazo/tenant_helpers.py index 71e723a..26005c7 100644 --- a/wazo/tenant_helpers.py +++ b/wazo/tenant_helpers.py @@ -5,8 +5,9 @@ from typing import TYPE_CHECKING, Any, TypeVar import requests -from xivo import rest_api_helpers -from xivo.http_exceptions import AuthServerUnreachable, InvalidTokenAPIException + +from wazo import rest_api_helpers +from wazo.http_exceptions import AuthServerUnreachable, InvalidTokenAPIException # Necessary to avoid a dependency in provd try: diff --git a/wazo/tests/test_caller_id.py b/wazo/tests/test_caller_id.py index 8e62183..684b919 100644 --- a/wazo/tests/test_caller_id.py +++ b/wazo/tests/test_caller_id.py @@ -1,11 +1,12 @@ -# Copyright 2013-2023 The Wazo Authors (see the AUTHORS file) +# Copyright 2013-2024 The Wazo Authors (see the AUTHORS file) # SPDX-License-Identifier: GPL-3.0-or-later import unittest from hamcrest import assert_that, equal_to -from xivo import caller_id -from xivo.caller_id import extract_displayname, extract_number, is_complete_caller_id + +from wazo import caller_id +from wazo.caller_id import extract_displayname, extract_number, is_complete_caller_id class TestCallerID(unittest.TestCase): diff --git a/wazo/tests/test_config_helper.py b/wazo/tests/test_config_helper.py index 558e68c..7bb49aa 100644 --- a/wazo/tests/test_config_helper.py +++ b/wazo/tests/test_config_helper.py @@ -1,4 +1,4 @@ -# Copyright 2014-2023 The Wazo Authors (see the AUTHORS file) +# Copyright 2014-2024 The Wazo Authors (see the AUTHORS file) # SPDX-License-Identifier: GPL-3.0-or-later import os.path @@ -332,11 +332,11 @@ def test_that_list_accumulates_all_values(self): class TestGetXiVOUUID(unittest.TestCase): - @patch('xivo.config_helper.os.getenv', return_value=False) + @patch('wazo.config_helper.os.getenv', return_value=False) def test_given_no_uuid_then_raise_error(self, getenv): assert_that(calling(get_xivo_uuid).with_args(Mock()), raises(UUIDNotFound)) - @patch('xivo.config_helper.os.getenv', return_value=XIVO_UUID) + @patch('wazo.config_helper.os.getenv', return_value=XIVO_UUID) def test_given_uuid_then_return_uuid(self, getenv): result = get_xivo_uuid(Mock()) @@ -344,11 +344,11 @@ def test_given_uuid_then_return_uuid(self, getenv): class TestSetXiVOUUID(unittest.TestCase): - @patch('xivo.config_helper.os.getenv', return_value=False) + @patch('wazo.config_helper.os.getenv', return_value=False) def test_given_no_uuid_then_raise_error(self, getenv): assert_that(calling(set_xivo_uuid).with_args({}, Mock()), raises(UUIDNotFound)) - @patch('xivo.config_helper.os.getenv', return_value=XIVO_UUID) + @patch('wazo.config_helper.os.getenv', return_value=XIVO_UUID) def test_given_uuid_then_set_uuid(self, getenv): config: dict[str, str] = {} set_xivo_uuid(config, Mock()) diff --git a/wazo/tests/test_consul_helpers.py b/wazo/tests/test_consul_helpers.py index fe42eab..f2f7b7b 100644 --- a/wazo/tests/test_consul_helpers.py +++ b/wazo/tests/test_consul_helpers.py @@ -31,7 +31,7 @@ class TestFindIpAddress(unittest.TestCase): def test_that_the_main_iface_is_used_if_it_has_an_ip_address(self): - with patch('xivo.consul_helpers.netifaces') as netifaces: + with patch('wazo.consul_helpers.netifaces') as netifaces: netifaces.interfaces.return_value = ['lo', 'eth0', 'eth1', 'eth3'] netifaces.ifaddresses.return_value = { netifaces.AF_INET: [{'addr': s.eth3_ip}] @@ -52,7 +52,7 @@ def return_values(iface): elif iface == 'eth0': return {netifaces.AF_INET: [{'broadcast': '255.255.255.0'}]} - with patch('xivo.consul_helpers.netifaces') as netifaces: + with patch('wazo.consul_helpers.netifaces') as netifaces: netifaces.interfaces.return_value = ['lo', 'eth0', 'eth1', 'eth3'] netifaces.ifaddresses.side_effect = return_values @@ -71,7 +71,7 @@ def return_values(iface): else: return {} - with patch('xivo.consul_helpers.netifaces') as netifaces: + with patch('wazo.consul_helpers.netifaces') as netifaces: netifaces.interfaces.return_value = ['lo', 'ens1', 'eno3', 'enp0s1'] netifaces.ifaddresses.side_effect = return_values @@ -90,7 +90,7 @@ def return_values(iface): else: return {} - with patch('xivo.consul_helpers.netifaces') as netifaces: + with patch('wazo.consul_helpers.netifaces') as netifaces: netifaces.interfaces.return_value = ['lo', 'eth0', 'eth1', 'eth2', 'eth3'] netifaces.ifaddresses.side_effect = return_values @@ -103,7 +103,7 @@ def return_values(iface): assert_that(result, equal_to(s.lo_ip)) def test_that_127001_is_returned_if_all_else_fails(self): - with patch('xivo.consul_helpers.netifaces') as netifaces: + with patch('wazo.consul_helpers.netifaces') as netifaces: netifaces.interfaces.return_value = ['lo', 'eth0', 'eth1'] netifaces.ifaddresses.return_value = {} @@ -114,7 +114,7 @@ def test_that_127001_is_returned_if_all_else_fails(self): assert_that(result, equal_to('127.0.0.1')) def test_that_an_invalid_iface_does_not_raise(self): - with patch('xivo.consul_helpers.netifaces') as netifaces: + with patch('wazo.consul_helpers.netifaces') as netifaces: netifaces.interfaces.return_value = ['lo', 'eth0', 'eth1'] netifaces.ifaddresses.side_effect = ValueError @@ -148,7 +148,7 @@ def setUp(self): ) self.service_id = self.registerer._service_id - @patch('xivo.consul_helpers.Consul', Mock()) + @patch('wazo.consul_helpers.Consul', Mock()) def test_that_register_sends_a_service_registered_event_when_registered(self): with patch.object(self.registerer, '_notify') as send_msg: self.registerer.register() @@ -163,7 +163,7 @@ def test_that_register_sends_a_service_registered_event_when_registered(self): send_msg.assert_called_once_with(expected_message) - @patch('xivo.consul_helpers.Consul') + @patch('wazo.consul_helpers.Consul') def test_that_deregister_sends_a_service_deregistered_event_when_registered( self, Consul ): @@ -179,7 +179,7 @@ def test_that_deregister_sends_a_service_deregistered_event_when_registered( send_msg.assert_called_once_with(expected_message) - @patch('xivo.consul_helpers.Consul') + @patch('wazo.consul_helpers.Consul') def test_that_deregister_sends_a_service_deregistered_event_when_not_registered( self, Consul ): @@ -209,7 +209,7 @@ def setUp(self): self.service_name, UUID, consul_config, service_discovery_config ) - @patch('xivo.consul_helpers.Consul') + @patch('wazo.consul_helpers.Consul') def test_that_register_calls_agent_register(self, Consul): consul_client = Consul.return_value @@ -227,7 +227,7 @@ def test_that_register_calls_agent_register(self, Consul): tags=[UUID, self.service_name], ) - @patch('xivo.consul_helpers.Consul') + @patch('wazo.consul_helpers.Consul') def test_that_register_raises_if_register_fails(self, Consul): consul_client = Consul.return_value consul_client.agent.service.register.return_value = False @@ -243,7 +243,7 @@ def test_that_register_raises_if_register_fails(self, Consul): tags=[UUID, self.service_name], ) - @patch('xivo.consul_helpers.Consul') + @patch('wazo.consul_helpers.Consul') def test_that_deregister_calls_agent_deregister_service_and_check(self, Consul): consul_client = Consul.return_value @@ -271,7 +271,7 @@ def setUp(self): } -@patch('xivo.consul_helpers.requests') +@patch('wazo.consul_helpers.requests') class TestRemoteServiceFinderGetDatacenters(BaseFinderTestCase): def test_that_the_url_matches_the_config(self, requests): requests.get.return_value = Mock(status_code=200) @@ -318,7 +318,7 @@ def test_that_health_uses_the_configured_verify(self, requests): requests.reset_mock() -@patch('xivo.consul_helpers.requests') +@patch('wazo.consul_helpers.requests') class TestRemoteServiceFinderListRunningServices(BaseFinderTestCase): def test_that_the_health_url_matches_the_config(self, requests): requests.get.return_value = Mock(status_code=200, json=Mock(return_value=[])) diff --git a/wazo/tests/test_daemonize.py b/wazo/tests/test_daemonize.py index 9d7831e..9037678 100644 --- a/wazo/tests/test_daemonize.py +++ b/wazo/tests/test_daemonize.py @@ -1,14 +1,14 @@ -# Copyright 2014-2023 The Wazo Authors (see the AUTHORS file) +# Copyright 2014-2024 The Wazo Authors (see the AUTHORS file) # SPDX-License-Identifier: GPL-3.0-or-later import unittest from unittest.mock import patch, sentinel -from xivo import daemonize +from wazo import daemonize -@patch('xivo.daemonize.unlock_pidfile') -@patch('xivo.daemonize.lock_pidfile_or_die') +@patch('wazo.daemonize.unlock_pidfile') +@patch('wazo.daemonize.lock_pidfile_or_die') class TestPidfileContext(unittest.TestCase): def test_that_lock_is_called(self, lock_fn, _unlock_fn): with daemonize.pidfile_context(sentinel.filename): diff --git a/wazo/tests/test_http_helpers.py b/wazo/tests/test_http_helpers.py index a22a432..e8c0631 100644 --- a/wazo/tests/test_http_helpers.py +++ b/wazo/tests/test_http_helpers.py @@ -1,4 +1,4 @@ -# Copyright 2016-2023 The Wazo Authors (see the AUTHORS file) +# Copyright 2016-2024 The Wazo Authors (see the AUTHORS file) # SPDX-License-Identifier: GPL-3.0-or-later import json @@ -6,7 +6,8 @@ from unittest.mock import ANY, Mock, patch from hamcrest import assert_that, equal_to -from xivo.http_helpers import ( + +from wazo.http_helpers import ( BodyFormatter, LazyHeaderFormatter, log_request, @@ -20,7 +21,7 @@ def _assert_json_equals(result, expected): class TestLogRequest(unittest.TestCase): - @patch('xivo.http_helpers.g', spec={}) + @patch('wazo.http_helpers.g', spec={}) def test_log_request(self, g): del g.request_time mock_request = Mock() @@ -28,8 +29,8 @@ def test_log_request(self, g): response = Mock(data=None, status_code=200) with ( - patch('xivo.http_helpers.request', mock_request), - patch('xivo.http_helpers.current_app', Mock()) as mock_current_app, + patch('wazo.http_helpers.request', mock_request), + patch('wazo.http_helpers.current_app', Mock()) as mock_current_app, ): log_request(response) @@ -42,7 +43,7 @@ def test_log_request(self, g): 200, ) - @patch('xivo.http_helpers.g', spec={}) + @patch('wazo.http_helpers.g', spec={}) def test_log_request_hide_token(self, g): del g.request_time mock_request = Mock() @@ -50,8 +51,8 @@ def test_log_request_hide_token(self, g): response = Mock(data=None, status_code=200) with ( - patch('xivo.http_helpers.request', mock_request), - patch('xivo.http_helpers.current_app', Mock()) as mock_current_app, + patch('wazo.http_helpers.request', mock_request), + patch('wazo.http_helpers.current_app', Mock()) as mock_current_app, ): log_request_hide_token(response) @@ -65,7 +66,7 @@ def test_log_request_hide_token(self, g): 200, ) - @patch('xivo.http_helpers.g', spec={}) + @patch('wazo.http_helpers.g', spec={}) def test_log_with_duration(self, g): g.request_time = 1667410149.0782132 mock_request = Mock() @@ -73,8 +74,8 @@ def test_log_with_duration(self, g): response = Mock(data=None, status_code=200) with ( - patch('xivo.http_helpers.request', mock_request), - patch('xivo.http_helpers.current_app', Mock()) as mock_current_app, + patch('wazo.http_helpers.request', mock_request), + patch('wazo.http_helpers.current_app', Mock()) as mock_current_app, ): log_request(response) diff --git a/wazo/tests/test_pubsub.py b/wazo/tests/test_pubsub.py index 7cf8e42..c40fd10 100644 --- a/wazo/tests/test_pubsub.py +++ b/wazo/tests/test_pubsub.py @@ -1,4 +1,4 @@ -# Copyright 2013-2023 The Wazo Authors (see the AUTHORS file) +# Copyright 2013-2024 The Wazo Authors (see the AUTHORS file) # SPDX-License-Identifier: GPL-3.0-or-later import unittest @@ -97,7 +97,7 @@ def test_when_exception_then_exception_is_handled(self): handler.assert_called_once_with(callback, SOME_MESSAGE, exception) - @patch('xivo.pubsub.logger') + @patch('wazo.pubsub.logger') def test_when_exception_then_exception_is_logged_by_default(self, logger): callback = Mock() exception = callback.side_effect = Exception() diff --git a/wazo/tests/test_rest_api_helpers.py b/wazo/tests/test_rest_api_helpers.py index 8e62058..c7daa4e 100644 --- a/wazo/tests/test_rest_api_helpers.py +++ b/wazo/tests/test_rest_api_helpers.py @@ -1,4 +1,4 @@ -# Copyright 2016-2023 The Wazo Authors (see the AUTHORS file) +# Copyright 2016-2024 The Wazo Authors (see the AUTHORS file) # SPDX-License-Identifier: GPL-3.0-or-later from unittest import TestCase @@ -90,7 +90,7 @@ def decorated(): ), ) - @patch('xivo.rest_api_helpers.logger') + @patch('wazo.rest_api_helpers.logger') def test_given_api_exception_when_handle_api_exception_then_logs_error( self, logger ): diff --git a/wazo/tests/test_tenant_flask_helpers.py b/wazo/tests/test_tenant_flask_helpers.py index ce7b916..ed63ffd 100644 --- a/wazo/tests/test_tenant_flask_helpers.py +++ b/wazo/tests/test_tenant_flask_helpers.py @@ -10,7 +10,7 @@ class TestAuthClient(unittest.TestCase): - @patch('xivo.tenant_flask_helpers.AuthClient') + @patch('wazo.tenant_flask_helpers.AuthClient') def test_config_deleted(self, auth_client): g_mock = Mock() g_mock.get.return_value = None @@ -22,8 +22,8 @@ def test_config_deleted(self, auth_client): } current_app_mock = Mock(config={'auth': config}) - with patch('xivo.tenant_flask_helpers.current_app', current_app_mock): - with patch('xivo.tenant_flask_helpers.g', g_mock): + with patch('wazo.tenant_flask_helpers.current_app', current_app_mock): + with patch('wazo.tenant_flask_helpers.g', g_mock): auth_client_proxy.host expected_config = {'host': s.host} @@ -31,7 +31,7 @@ def test_config_deleted(self, auth_client): class TestTenant(unittest.TestCase): - @patch('xivo.tenant_flask_helpers.AuthClient') + @patch('wazo.tenant_flask_helpers.AuthClient') def test_autodetect_when_verified_tenant_uuid(self, auth_client): g_mock = Mock() g_data = {'verified_tenant_uuid': s.tenant} @@ -40,8 +40,8 @@ def test_autodetect_when_verified_tenant_uuid(self, auth_client): request_mock.headers.get.return_value = s.tenant request_mock.args = [] - with patch('xivo.tenant_flask_helpers.g', g_mock): - with patch('xivo.flask.headers.request', request_mock): + with patch('wazo.tenant_flask_helpers.g', g_mock): + with patch('wazo.flask.headers.request', request_mock): tenant = Tenant.autodetect() assert tenant.uuid == s.tenant diff --git a/wazo/tests/test_tenant_helpers.py b/wazo/tests/test_tenant_helpers.py index f5c0b67..a6b4c37 100644 --- a/wazo/tests/test_tenant_helpers.py +++ b/wazo/tests/test_tenant_helpers.py @@ -14,14 +14,15 @@ ) from requests import HTTPError, RequestException from wazo_test_helpers.hamcrest.raises import raises -from xivo.auth_verifier import AuthServerUnreachable, InvalidTokenAPIException + +from wazo.auth_verifier import AuthServerUnreachable, InvalidTokenAPIException from ..tenant_helpers import InvalidTenant, Tenant, Token, UnauthorizedTenant class TestTenantAutodetect(TestCase): - @patch('xivo.tenant_helpers.Token') - @patch('xivo.flask.headers.request', spec={}) + @patch('wazo.tenant_helpers.Token') + @patch('wazo.flask.headers.request', spec={}) def test_given_no_token_when_autodetect_then_raise(self, request, Token): auth = Mock() Token.from_headers = Mock() @@ -33,8 +34,8 @@ def test_given_no_token_when_autodetect_then_raise(self, request, Token): calling(Tenant.autodetect).with_args(auth), raises(InvalidTokenAPIException) ) - @patch('xivo.tenant_helpers.Token') - @patch('xivo.flask.headers.request', spec={}) + @patch('wazo.tenant_helpers.Token') + @patch('wazo.flask.headers.request', spec={}) def test_given_token_no_tenant_when_autodetect_then_return_tenant_from_token( self, request, Token ): @@ -49,8 +50,8 @@ def test_given_token_no_tenant_when_autodetect_then_return_tenant_from_token( assert_that(result.uuid, equal_to(tenant)) - @patch('xivo.tenant_helpers.Token') - @patch('xivo.flask.headers.request', spec={}) + @patch('wazo.tenant_helpers.Token') + @patch('wazo.flask.headers.request', spec={}) def test_given_token_and_tenant_when_autodetect_then_return_given_tenant( self, request, Token ): @@ -65,8 +66,8 @@ def test_given_token_and_tenant_when_autodetect_then_return_given_tenant( assert_that(result.uuid, equal_to(tenant)) - @patch('xivo.tenant_helpers.Token') - @patch('xivo.flask.headers.request', spec={}) + @patch('wazo.tenant_helpers.Token') + @patch('wazo.flask.headers.request', spec={}) def test_given_token_unknown_tenant_and_user_in_tenant_when_autodetect_then_return_tenant( self, request, Token ): @@ -83,8 +84,8 @@ def test_given_token_unknown_tenant_and_user_in_tenant_when_autodetect_then_retu assert_that(result.uuid, equal_to(tenant)) - @patch('xivo.tenant_helpers.Token') - @patch('xivo.flask.headers.request', spec={}) + @patch('wazo.tenant_helpers.Token') + @patch('wazo.flask.headers.request', spec={}) def test_given_token_unknown_tenant_and_user_not_in_tenant_when_autodetect_then_raise( self, request, Token ): @@ -111,13 +112,13 @@ def test_given_visible_tenants_called_twice_with_same_tenant(self): class TestTenantFromHeaders(TestCase): - @patch('xivo.flask.headers.request', spec={}) + @patch('wazo.flask.headers.request', spec={}) def test_given_no_tenant_when_from_headers_then_raise(self, request): request.headers = {} assert_that(calling(Tenant.from_headers), raises(InvalidTenant)) - @patch('xivo.flask.headers.request', spec={}) + @patch('wazo.flask.headers.request', spec={}) def test_given_tenant_when_from_headers_then_return_tenant(self, request): tenant = 'tenant' request.headers = {'Wazo-Tenant': tenant} @@ -128,13 +129,13 @@ def test_given_tenant_when_from_headers_then_return_tenant(self, request): class TestTenantFromQuery(TestCase): - @patch('xivo.tenant_helpers.request', spec={}) + @patch('wazo.tenant_helpers.request', spec={}) def test_given_no_tenant_when_from_query_then_raise(self, mock_request): mock_request.args = {} assert_that(calling(Tenant.from_query), raises(InvalidTenant)) - @patch('xivo.tenant_helpers.request', spec={}) + @patch('wazo.tenant_helpers.request', spec={}) def test_given_tenant_when_from_query_then_return_tenant(self, mock_request): tenant = 'tenant' mock_request.args = {'tenant': tenant} @@ -199,7 +200,7 @@ def test_when_has_no_tenant_access(self): class TestTokenFromHeaders(TestCase): - @patch('xivo.tenant_helpers.extract_token_id_from_header') + @patch('wazo.tenant_helpers.extract_token_id_from_header') def test_given_valid_header(self, extract): token_id = 'my-valid-uuid' extract.return_value = token_id @@ -209,7 +210,7 @@ def test_given_valid_header(self, extract): assert_that(token.uuid, equal_to(token_id)) - @patch('xivo.tenant_helpers.extract_token_id_from_header') + @patch('wazo.tenant_helpers.extract_token_id_from_header') def test_given_no_header_when_get_then_raise(self, extract): extract.return_value = '' auth = Mock() diff --git a/wazo/tests/test_user_rights.py b/wazo/tests/test_user_rights.py index 34237bc..a87e47b 100644 --- a/wazo/tests/test_user_rights.py +++ b/wazo/tests/test_user_rights.py @@ -1,4 +1,4 @@ -# Copyright 2014-2023 The Wazo Authors (see the AUTHORS file) +# Copyright 2014-2024 The Wazo Authors (see the AUTHORS file) # SPDX-License-Identifier: GPL-3.0-or-later @@ -12,7 +12,7 @@ GROUP_ID = 42 -@patch('xivo.user_rights.getpwnam') +@patch('wazo.user_rights.getpwnam') @patch('os.setuid') @patch('os.setgid') @patch('os.initgroups') diff --git a/wazo/tests/test_xivo_helpers.py b/wazo/tests/test_xivo_helpers.py index 9e810be..0e6d1b2 100644 --- a/wazo/tests/test_xivo_helpers.py +++ b/wazo/tests/test_xivo_helpers.py @@ -1,9 +1,9 @@ -# Copyright 2013-2023 The Wazo Authors (see the AUTHORS file) +# Copyright 2013-2024 The Wazo Authors (see the AUTHORS file) # SPDX-License-Identifier: GPL-3.0-or-later import unittest -from xivo import xivo_helpers +from wazo import xivo_helpers class TestXivoHelpers(unittest.TestCase): diff --git a/wazo/tests/test_xivo_logging.py b/wazo/tests/test_xivo_logging.py index d162cf5..39e62de 100644 --- a/wazo/tests/test_xivo_logging.py +++ b/wazo/tests/test_xivo_logging.py @@ -1,4 +1,4 @@ -# Copyright 2014-2023 The Wazo Authors (see the AUTHORS file) +# Copyright 2014-2024 The Wazo Authors (see the AUTHORS file) # SPDX-License-Identifier: GPL-3.0-or-later import logging @@ -17,7 +17,8 @@ is_, is_not, ) -from xivo.xivo_logging import ( + +from wazo.xivo_logging import ( DEFAULT_LOG_FORMAT, DEFAULT_LOG_LEVEL, excepthook, @@ -27,7 +28,7 @@ ) -@patch('xivo.xivo_logging.logging') +@patch('wazo.xivo_logging.logging') class TestLogging(TestCase): def test_setup_logging_with_log_file_then_setup_logging_in_log_file(self, logging): log_file = 'my_log_file.log' @@ -172,7 +173,7 @@ def test_get_log_level_by_name_when_valid_lower_name_then_return_log_level(self) class TestSilenceLoggers(TestCase): - @patch('xivo.xivo_logging.logging') + @patch('wazo.xivo_logging.logging') def test_that_loggers_are_leveled_down(self, mocked_logging): loggers = {} to_silence = ['one', 'two', 'three'] diff --git a/wazo/user_rights.py b/wazo/user_rights.py index ca82401..bdf4edb 100644 --- a/wazo/user_rights.py +++ b/wazo/user_rights.py @@ -1,11 +1,11 @@ -# Copyright 2014-2023 The Wazo Authors (see the AUTHORS file) +# Copyright 2014-2024 The Wazo Authors (see the AUTHORS file) # SPDX-License-Identifier: GPL-3.0-or-later from __future__ import annotations import os from pwd import getpwnam -from xivo.xivo_helpers import abort +from wazo.xivo_helpers import abort def change_user(user: str) -> None: