Skip to content

core.admins functionality is not tested #2734

@SnoopJ

Description

@SnoopJ

On #2733, @dgw pointed out that the core.admins config field also should be documented as accepting the nick@host format, which made me realize that the functionality of this field (with respect to Trigger) is not being tested.

The proof of the pudding is in the pytesting, so here's a diff that deletes part of the check:

diff --git a/sopel/trigger.py b/sopel/trigger.py
index 0fae5bc3..e9ac461d 100644
--- a/sopel/trigger.py
+++ b/sopel/trigger.py
@@ -557,7 +557,5 @@ class Trigger(str):
         else:
             self._owner = match_host_or_nick(settings.core.owner)
         self._admin = (
-            self._owner or
-            self.account in settings.core.admin_accounts or
-            any(match_host_or_nick(item) for item in settings.core.admins)
+            self._owner
         )

With this diff applied, the test suite experiences no failures:

$ PYTEST_ADDOPTS="-x" make test                                                                                                                                                              
coverage run -m pytest -v
==================================================================================== test session starts ====================================================================================
platform linux -- Python 3.9.16, pytest-7.4.4, pluggy-1.6.0 -- /var/lib/gitea/data/gitea-repositories/snoopj/sopel.git/env/3.8/bin/python3                                                   
cachedir: .pytest_cache
rootdir: /var/lib/gitea/data/gitea-repositories/snoopj/sopel.git                              
configfile: pyproject.toml
testpaths: test, sopel   
plugins: sopel-8.1.0.dev0, requests-mock-1.9.3, vcr-1.0.2                                     
collected 1453 items

... snip ...

=================== 1445 passed, 8 xfailed, 1 warning in 60.56s (0:01:00) ===================

We should add tests to test_trigger.py that cover this feature (for both a list of nicks and a list of nick@host)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions