File tree Expand file tree Collapse file tree 5 files changed +28
-2
lines changed Expand file tree Collapse file tree 5 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,11 @@ async def on_ready():
18
18
async def ping (ctx ):
19
19
await ctx .send ("Pong!" )
20
20
21
+ @bot .command ()
22
+ async def version (ctx ):
23
+ app_version = settings .APP_VERSION
24
+ await ctx .send (f"Version: { app_version } " )
25
+
21
26
22
27
def run_bot ():
23
28
bot_token = settings .DISCORD_BOT_TOKEN
Original file line number Diff line number Diff line change 1
1
from django .http .response import JsonResponse
2
+ from django .conf import settings
2
3
3
4
4
5
def index (request ):
5
- return JsonResponse ({"hello" : "world" })
6
+ return JsonResponse (
7
+ {
8
+ "hello" : "world" ,
9
+ "v" : settings .APP_VERSION ,
10
+ }
11
+ )
Original file line number Diff line number Diff line change 108
108
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
109
109
110
110
DJANGO_ENV = os .environ ["DJANGO_ENV" ]
111
+ APP_VERSION = os .environ .get ("APP_VERSION" , "latest" )[:8 ]
111
112
112
113
if DJANGO_ENV == "dev" :
113
114
DEBUG = True
Original file line number Diff line number Diff line change 11
11
"""
12
12
13
13
from django .contrib .auth .models import User
14
+ from django .conf import settings
14
15
import pytest
15
16
16
17
@@ -28,3 +29,4 @@ def test_http_sanity_check(client):
28
29
assert response .status_code == 200
29
30
assert response ["Content-Type" ] == "application/json"
30
31
assert response .json ()["hello" ] == "world"
32
+ assert response .json ()["v" ] == settings .APP_VERSION
Original file line number Diff line number Diff line change 1
1
from unittest .mock import AsyncMock
2
2
3
3
import pytest
4
- from core .bot .main import ping
4
+ from core .bot .main import ping , version
5
5
6
6
7
7
@pytest .mark .asyncio
@@ -14,3 +14,15 @@ async def test_ping_command():
14
14
15
15
# Assert that the command sent the expected message
16
16
ctx .send .assert_called_once_with ("Pong!" )
17
+
18
+
19
+ @pytest .mark .asyncio
20
+ async def test_version_command ():
21
+ # Mock context
22
+ ctx = AsyncMock ()
23
+
24
+ # Call the command
25
+ await version (ctx )
26
+
27
+ # Assert that the command sent the expected message
28
+ ctx .send .assert_called_once_with ("Version: latest" )
You can’t perform that action at this time.
0 commit comments