Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,16 @@ def init(self) -> None:
db_teams = Team.get_all_team_names()

if not db_teams.issuperset(am_teams):
raise ValueError(
f"Teams defined in the auth manager ({am_teams}) are not present in the database ({db_teams})."
warnings.warn(
f"Teams defined in the auth manager are not present in the database ({am_teams.difference(db_teams)}).",
UserWarning,
stacklevel=2,
)
if not am_teams.issuperset(db_teams):
warnings.warn(
f"Teams defined in the database are not present in the auth manager ({db_teams.difference(am_teams)}).",
UserWarning,
stacklevel=2,
)

@abstractmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,11 @@ def test_init_non_multi_team_mode(self, auth_manager):
@pytest.mark.parametrize(
("auth_manager_teams", "db_teams", "expected"),
[
({"teamA", "teamB"}, {"teamA", "teamB"}, True),
({"teamA", "teamB"}, {"teamA", "teamB", "teamC"}, True),
(set(), set(), True),
({"teamA", "teamB"}, {"teamA", "teamC"}, False),
pytest.param({"teamA", "teamB"}, {"teamA", "teamB"}, "same", id="same teams"),
pytest.param({"teamA", "teamB"}, {"teamA", "teamB", "teamC"}, "extra_db", id="extra teams db"),
pytest.param(set(), set(), "same", id="no teams"),
pytest.param({"teamA", "teamB"}, {"teamA"}, "extra_auth", id="extra teams auth"),
pytest.param({"teamA", "teamB"}, {"teamA", "teamC"}, "extra_both", id="extra teams both"),
],
)
@patch.object(Team, "get_all_team_names")
Expand All @@ -175,10 +176,19 @@ def test_init_multi_team_mode(
mock_get_teams.return_value = auth_manager_teams
mock_get_all_team_names.return_value = db_teams

if expected:
if expected == "same":
assert auth_manager.init() is None
elif expected == "extra_auth":
with pytest.warns(UserWarning, match="Teams defined in the auth manager"):
auth_manager.init()
elif expected == "extra_db":
with pytest.warns(UserWarning, match="Teams defined in the database"):
auth_manager.init()
else:
with pytest.raises(ValueError, match="Teams defined in the auth manager"):
with (
pytest.warns(UserWarning, match="Teams defined in the database"),
pytest.warns(UserWarning, match="Teams defined in the auth manager"),
):
auth_manager.init()

def test_get_cli_commands_return_empty_list(self, auth_manager):
Expand Down
Loading