File tree Expand file tree Collapse file tree 6 files changed +27
-8
lines changed Expand file tree Collapse file tree 6 files changed +27
-8
lines changed Original file line number Diff line number Diff line change
1
+ import logging
2
+
1
3
from aiohttp import web
2
4
3
5
from pyslackersweb .sirbot .views import readthedocs , slack
4
6
7
+ from . import settings
8
+
9
+ logger = logging .getLogger (__name__ )
10
+
5
11
6
12
async def app_factory () -> web .Application :
7
13
sirbot = web .Application ()
@@ -11,6 +17,9 @@ async def app_factory() -> web.Application:
11
17
scheduler = None , # populated via parent app signal
12
18
)
13
19
20
+ if not settings .SLACK_SIGNING_SECRET :
21
+ logger .error ("Environment variable 'SLACK_SIGNING_SECRET' not set" )
22
+
14
23
readthedocs .add_routes (sirbot .router )
15
24
slack .add_routes (sirbot .router )
16
25
return sirbot
Original file line number Diff line number Diff line change 1
1
import os
2
- import logging
3
2
4
3
IS_PRODUCTION = os .environ .get ("PLATFORM_BRANCH" ) == "master"
5
4
6
5
# production settings
7
6
READTHEDOCS_NOTIFICATION_CHANNEL = "community_projects"
8
7
SLACK_TEAM_ID = os .environ .get ("SLACK_TEAM_ID" )
9
8
SLACK_SIGNING_SECRET = os .environ .get ("SLACK_SIGNING_SECRET" , "" )
10
- if not SLACK_SIGNING_SECRET :
11
- logging .error ("Environment variable 'SLACK_SIGNING_SECRET' not set" )
12
9
13
10
# Development settings
14
11
if not IS_PRODUCTION :
File renamed without changes.
Original file line number Diff line number Diff line change 4
4
from slack .sansio import validate_request_signature
5
5
6
6
from pyslackersweb .sirbot import settings
7
-
8
- from . import commands
7
+ from pyslackersweb .sirbot .slack import commands
9
8
10
9
11
10
def add_routes (router : web .UrlDispatcher ) -> None :
Original file line number Diff line number Diff line change
1
+ [pytest]
2
+ # https://docs.pytest.org/en/latest/deprecations.html#junit-family-default-value-change-to-xunit2
3
+ junit_family =legacy
Original file line number Diff line number Diff line change 1
1
import pytest
2
2
3
- from unittest import mock
4
-
5
3
import pyslackersweb
6
4
import pyslackersweb .website .tasks
7
5
11
9
pytest_plugins = ("slack.tests.plugin" ,)
12
10
13
11
12
+ @pytest .fixture ()
13
+ async def slack_client_ctx (slack_client ):
14
+ async def ctx (app ):
15
+ pyslackersweb .contexts ._register_in_app (app , "slack_client" , slack_client )
16
+ pyslackersweb .contexts ._register_in_app (app , "slack_client_legacy" , slack_client )
17
+ yield
18
+
19
+ return ctx
20
+
21
+
14
22
@pytest .fixture
15
- async def client (aiohttp_client , slack_client ):
23
+ async def client (monkeypatch , aiohttp_client , slack_client_ctx ):
24
+
25
+ # Patch imported slack_client context in pyslackersweb/__init__.py with the fake slack client ctx
26
+ monkeypatch .setattr (pyslackersweb , "slack_client" , slack_client_ctx )
16
27
17
28
application = await pyslackersweb .app_factory ()
18
29
You can’t perform that action at this time.
0 commit comments