Skip to content

Commit

Permalink
Parse test_rooms.yml in each test using privileged commands.
Browse files Browse the repository at this point in the history
This should partially resolve #6955. There's at least one more
test failing intermittently, but this should resolve the majority.

autopull
  • Loading branch information
makyen committed May 8, 2022
1 parent 7065417 commit 2a92089
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/test_chatcommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,12 +220,15 @@ def test_privileged():


def test_deprecated_blacklist():
chatcommunicate.parse_room_config("test/test_rooms.yml")
assert chatcommands.blacklist("").startswith("The `!!/blacklist` command has been deprecated.")


@pytest.mark.skipif(GlobalVars.on_branch != "master", reason="avoid branch checkout")
def test_watch(monkeypatch):
chatcommunicate.parse_room_config("test/test_rooms.yml")
# XXX TODO: expand

def wrap_watch(pattern, force=False):
cmd = 'watch{0}'.format('-force' if force else '')
msg = Fake({
Expand Down Expand Up @@ -276,6 +279,7 @@ def wrap_watch(pattern, force=False):


def test_approve(monkeypatch):
chatcommunicate.parse_room_config("test/test_rooms.yml")
msg = Fake({
"_client": {
"host": "stackexchange.com",
Expand All @@ -302,6 +306,7 @@ def test_approve(monkeypatch):


def test_reject(monkeypatch):
chatcommunicate.parse_room_config("test/test_rooms.yml")
msg = Fake({
"_client": {
"host": "stackexchange.com",
Expand Down Expand Up @@ -329,6 +334,7 @@ def test_reject(monkeypatch):

@patch("chatcommands.handle_spam")
def test_report(handle_spam):
chatcommunicate.parse_room_config("test/test_rooms.yml")
# Documentation: The process before scanning the post is identical regardless of alias_used.
# No need to supply alias_used to test that part.
# If no alias_used is supplied, it acts as if it's "scan"
Expand Down Expand Up @@ -412,6 +418,7 @@ def test_report(handle_spam):

@patch("chatcommands.handle_spam")
def test_allspam(handle_spam):
chatcommunicate.parse_room_config("test/test_rooms.yml")
try:
msg = Fake({
"owner": {
Expand Down Expand Up @@ -492,6 +499,7 @@ def test_allspam(handle_spam):

@pytest.mark.skipif(os.path.isfile("blacklistedUsers.p"), reason="shouldn't overwrite file")
def test_blacklisted_users():
chatcommunicate.parse_room_config("test/test_rooms.yml")
try:
msg = Fake({
"owner": {
Expand Down Expand Up @@ -563,6 +571,7 @@ def test_blacklisted_users():

@pytest.mark.skipif(os.path.isfile("whitelistedUsers.p"), reason="shouldn't overwrite file")
def test_whitelisted_users():
chatcommunicate.parse_room_config("test/test_rooms.yml")
try:
msg = Fake({
"owner": {
Expand Down Expand Up @@ -630,6 +639,7 @@ def test_whitelisted_users():


def test_metasmoke():
chatcommunicate.parse_room_config("test/test_rooms.yml")
orig_tell_rooms_with = chatcommunicate.tell_rooms_with
chatcommunicate.tell_rooms_with = dummy_tell_rooms_with
msg = Fake({
Expand Down Expand Up @@ -661,6 +671,7 @@ def test_metasmoke():

@pytest.mark.skipif(os.path.isfile("notifications.p"), reason="shouldn't overwrite file")
def test_notifications():
chatcommunicate.parse_room_config("test/test_rooms.yml")
try:
msg1 = Fake({
"owner": {
Expand Down Expand Up @@ -766,6 +777,7 @@ def test_notifications():


def test_inqueue():
chatcommunicate.parse_room_config("test/test_rooms.yml")
site = Fake({"keys": (lambda: ['1'])})

class FakeQueue:
Expand Down

0 comments on commit 2a92089

Please sign in to comment.