From e73f5bbc023734fdcf22e83bf204d36ed5c82d73 Mon Sep 17 00:00:00 2001 From: hyperbel Date: Tue, 4 Jul 2023 20:56:15 +0200 Subject: [PATCH] rewrite stuff --- README.md | 14 ------- endpoints.json | 38 ++++++++++++++++++ {Config => old/Config}/README.md | 0 {Config => old/Config}/log/README.md | 0 {Config => old/Config}/mate.json | 0 {Config => old/Config}/party.sql | 0 old/README.md | 14 +++++++ database.py => old/database.py | 0 endpoints.txt => old/endpoints.txt | 0 log.py => old/log.py | 0 main.py => old/main.py | 0 mate.py => old/mate.py | 0 musik.py => old/musik.py | 0 picker.py => old/picker.py | 0 requirements.txt => old/requirements.txt | 0 run.sh => old/run.sh | 0 server.py => old/server.py | 0 {static => old/static}/css/create_session.css | 0 {static => old/static}/css/login.css | 0 {static => old/static}/css/style.css | 0 {static => old/static}/img/Balloons.png | Bin {static => old/static}/img/house.png | Bin {static => old/static}/img/party.png | Bin {static => old/static}/img/qrcode.png | Bin {static => old/static}/img/user.png | Bin {static => old/static}/js/chat.js | 0 {static => old/static}/js/control.js | 0 {static => old/static}/js/create_session.js | 0 {static => old/static}/js/game.js | 0 {static => old/static}/js/general.js | 0 {static => old/static}/js/login.js | 0 {static => old/static}/js/logout.js | 0 statistik.py => old/statistik.py | 0 {templates => old/templates}/404.html | 0 .../templates}/changeSession.html | 0 .../templates}/createSession.html | 0 {templates => old/templates}/index.html | 0 {templates => old/templates}/login.html | 0 {templates => old/templates}/logout.html | 0 {templates => old/templates}/messages.html | 0 {templates => old/templates}/passwd.html | 0 {templates => old/templates}/session.html | 0 {templates => old/templates}/spiel.html | 0 test.py => old/test.py | 0 {test => old/test}/main.py | 0 {test => old/test}/templates/index.html | 0 {upload => old/upload}/Dateien/README.md | 0 {upload => old/upload}/Musik/README.md | 0 {upload => old/upload}/README.md | 0 {upload => old/upload}/Spielstand/README.md | 0 party/.coverage | Bin 0 -> 53248 bytes party/__init__.py | 4 ++ party/main.py | 0 setup.py | 0 test/__init__.py | 8 ++++ test/test_server.py | 23 +++++++++++ 56 files changed, 87 insertions(+), 14 deletions(-) create mode 100644 endpoints.json rename {Config => old/Config}/README.md (100%) rename {Config => old/Config}/log/README.md (100%) rename {Config => old/Config}/mate.json (100%) rename {Config => old/Config}/party.sql (100%) create mode 100644 old/README.md rename database.py => old/database.py (100%) rename endpoints.txt => old/endpoints.txt (100%) rename log.py => old/log.py (100%) rename main.py => old/main.py (100%) rename mate.py => old/mate.py (100%) rename musik.py => old/musik.py (100%) rename picker.py => old/picker.py (100%) rename requirements.txt => old/requirements.txt (100%) rename run.sh => old/run.sh (100%) rename server.py => old/server.py (100%) rename {static => old/static}/css/create_session.css (100%) rename {static => old/static}/css/login.css (100%) rename {static => old/static}/css/style.css (100%) rename {static => old/static}/img/Balloons.png (100%) rename {static => old/static}/img/house.png (100%) rename {static => old/static}/img/party.png (100%) rename {static => old/static}/img/qrcode.png (100%) rename {static => old/static}/img/user.png (100%) rename {static => old/static}/js/chat.js (100%) rename {static => old/static}/js/control.js (100%) rename {static => old/static}/js/create_session.js (100%) rename {static => old/static}/js/game.js (100%) rename {static => old/static}/js/general.js (100%) rename {static => old/static}/js/login.js (100%) rename {static => old/static}/js/logout.js (100%) rename statistik.py => old/statistik.py (100%) rename {templates => old/templates}/404.html (100%) rename {templates => old/templates}/changeSession.html (100%) rename {templates => old/templates}/createSession.html (100%) rename {templates => old/templates}/index.html (100%) rename {templates => old/templates}/login.html (100%) rename {templates => old/templates}/logout.html (100%) rename {templates => old/templates}/messages.html (100%) rename {templates => old/templates}/passwd.html (100%) rename {templates => old/templates}/session.html (100%) rename {templates => old/templates}/spiel.html (100%) rename test.py => old/test.py (100%) rename {test => old/test}/main.py (100%) rename {test => old/test}/templates/index.html (100%) rename {upload => old/upload}/Dateien/README.md (100%) rename {upload => old/upload}/Musik/README.md (100%) rename {upload => old/upload}/README.md (100%) rename {upload => old/upload}/Spielstand/README.md (100%) create mode 100644 party/.coverage create mode 100644 party/__init__.py create mode 100644 party/main.py create mode 100644 setup.py create mode 100644 test/__init__.py create mode 100644 test/test_server.py diff --git a/README.md b/README.md index df4b2e0..e69de29 100644 --- a/README.md +++ b/README.md @@ -1,14 +0,0 @@ -# Party Controller -Dies ist eine Software für Lan Partys - - -## Server starten -+ Clonen `git clone https://github.com/fingadumbledore/Party` - -### Nativ: -+ Wechseln`cd Party` -+ starten`./run.sh` - -### Mit Nix -+ `nix-shell` -+ `bash run.sh` diff --git a/endpoints.json b/endpoints.json new file mode 100644 index 0000000..85754a0 --- /dev/null +++ b/endpoints.json @@ -0,0 +1,38 @@ +{ + "endpoints": [ + "/api": [ + { + "/mate": [ + { + "endpoint": "/", + "method":"GET" + }, + { + "endpoint": "/status", + "method":"GET" + }, + { + "endpoint": "/trinken", + "method":"POST" + } + ] + }, + { + "/chat": [ + { + "endpoint": "/", + "method":"GET" + }, + { + "endpoint": "/messages:count", + "method": "GET" + }, + { + "endpoint": "/new", + "method": "POST" + } + ] + } + ] + ] +} diff --git a/Config/README.md b/old/Config/README.md similarity index 100% rename from Config/README.md rename to old/Config/README.md diff --git a/Config/log/README.md b/old/Config/log/README.md similarity index 100% rename from Config/log/README.md rename to old/Config/log/README.md diff --git a/Config/mate.json b/old/Config/mate.json similarity index 100% rename from Config/mate.json rename to old/Config/mate.json diff --git a/Config/party.sql b/old/Config/party.sql similarity index 100% rename from Config/party.sql rename to old/Config/party.sql diff --git a/old/README.md b/old/README.md new file mode 100644 index 0000000..df4b2e0 --- /dev/null +++ b/old/README.md @@ -0,0 +1,14 @@ +# Party Controller +Dies ist eine Software für Lan Partys + + +## Server starten ++ Clonen `git clone https://github.com/fingadumbledore/Party` + +### Nativ: ++ Wechseln`cd Party` ++ starten`./run.sh` + +### Mit Nix ++ `nix-shell` ++ `bash run.sh` diff --git a/database.py b/old/database.py similarity index 100% rename from database.py rename to old/database.py diff --git a/endpoints.txt b/old/endpoints.txt similarity index 100% rename from endpoints.txt rename to old/endpoints.txt diff --git a/log.py b/old/log.py similarity index 100% rename from log.py rename to old/log.py diff --git a/main.py b/old/main.py similarity index 100% rename from main.py rename to old/main.py diff --git a/mate.py b/old/mate.py similarity index 100% rename from mate.py rename to old/mate.py diff --git a/musik.py b/old/musik.py similarity index 100% rename from musik.py rename to old/musik.py diff --git a/picker.py b/old/picker.py similarity index 100% rename from picker.py rename to old/picker.py diff --git a/requirements.txt b/old/requirements.txt similarity index 100% rename from requirements.txt rename to old/requirements.txt diff --git a/run.sh b/old/run.sh similarity index 100% rename from run.sh rename to old/run.sh diff --git a/server.py b/old/server.py similarity index 100% rename from server.py rename to old/server.py diff --git a/static/css/create_session.css b/old/static/css/create_session.css similarity index 100% rename from static/css/create_session.css rename to old/static/css/create_session.css diff --git a/static/css/login.css b/old/static/css/login.css similarity index 100% rename from static/css/login.css rename to old/static/css/login.css diff --git a/static/css/style.css b/old/static/css/style.css similarity index 100% rename from static/css/style.css rename to old/static/css/style.css diff --git a/static/img/Balloons.png b/old/static/img/Balloons.png similarity index 100% rename from static/img/Balloons.png rename to old/static/img/Balloons.png diff --git a/static/img/house.png b/old/static/img/house.png similarity index 100% rename from static/img/house.png rename to old/static/img/house.png diff --git a/static/img/party.png b/old/static/img/party.png similarity index 100% rename from static/img/party.png rename to old/static/img/party.png diff --git a/static/img/qrcode.png b/old/static/img/qrcode.png similarity index 100% rename from static/img/qrcode.png rename to old/static/img/qrcode.png diff --git a/static/img/user.png b/old/static/img/user.png similarity index 100% rename from static/img/user.png rename to old/static/img/user.png diff --git a/static/js/chat.js b/old/static/js/chat.js similarity index 100% rename from static/js/chat.js rename to old/static/js/chat.js diff --git a/static/js/control.js b/old/static/js/control.js similarity index 100% rename from static/js/control.js rename to old/static/js/control.js diff --git a/static/js/create_session.js b/old/static/js/create_session.js similarity index 100% rename from static/js/create_session.js rename to old/static/js/create_session.js diff --git a/static/js/game.js b/old/static/js/game.js similarity index 100% rename from static/js/game.js rename to old/static/js/game.js diff --git a/static/js/general.js b/old/static/js/general.js similarity index 100% rename from static/js/general.js rename to old/static/js/general.js diff --git a/static/js/login.js b/old/static/js/login.js similarity index 100% rename from static/js/login.js rename to old/static/js/login.js diff --git a/static/js/logout.js b/old/static/js/logout.js similarity index 100% rename from static/js/logout.js rename to old/static/js/logout.js diff --git a/statistik.py b/old/statistik.py similarity index 100% rename from statistik.py rename to old/statistik.py diff --git a/templates/404.html b/old/templates/404.html similarity index 100% rename from templates/404.html rename to old/templates/404.html diff --git a/templates/changeSession.html b/old/templates/changeSession.html similarity index 100% rename from templates/changeSession.html rename to old/templates/changeSession.html diff --git a/templates/createSession.html b/old/templates/createSession.html similarity index 100% rename from templates/createSession.html rename to old/templates/createSession.html diff --git a/templates/index.html b/old/templates/index.html similarity index 100% rename from templates/index.html rename to old/templates/index.html diff --git a/templates/login.html b/old/templates/login.html similarity index 100% rename from templates/login.html rename to old/templates/login.html diff --git a/templates/logout.html b/old/templates/logout.html similarity index 100% rename from templates/logout.html rename to old/templates/logout.html diff --git a/templates/messages.html b/old/templates/messages.html similarity index 100% rename from templates/messages.html rename to old/templates/messages.html diff --git a/templates/passwd.html b/old/templates/passwd.html similarity index 100% rename from templates/passwd.html rename to old/templates/passwd.html diff --git a/templates/session.html b/old/templates/session.html similarity index 100% rename from templates/session.html rename to old/templates/session.html diff --git a/templates/spiel.html b/old/templates/spiel.html similarity index 100% rename from templates/spiel.html rename to old/templates/spiel.html diff --git a/test.py b/old/test.py similarity index 100% rename from test.py rename to old/test.py diff --git a/test/main.py b/old/test/main.py similarity index 100% rename from test/main.py rename to old/test/main.py diff --git a/test/templates/index.html b/old/test/templates/index.html similarity index 100% rename from test/templates/index.html rename to old/test/templates/index.html diff --git a/upload/Dateien/README.md b/old/upload/Dateien/README.md similarity index 100% rename from upload/Dateien/README.md rename to old/upload/Dateien/README.md diff --git a/upload/Musik/README.md b/old/upload/Musik/README.md similarity index 100% rename from upload/Musik/README.md rename to old/upload/Musik/README.md diff --git a/upload/README.md b/old/upload/README.md similarity index 100% rename from upload/README.md rename to old/upload/README.md diff --git a/upload/Spielstand/README.md b/old/upload/Spielstand/README.md similarity index 100% rename from upload/Spielstand/README.md rename to old/upload/Spielstand/README.md diff --git a/party/.coverage b/party/.coverage new file mode 100644 index 0000000000000000000000000000000000000000..8adc4e8097dcb88c5fd650e014c7ace6bf35f88c GIT binary patch literal 53248 zcmeI)%WoS+90%~-Z0n8fL@tUVD@0Z1f*h-U#7!w`IY59MDk`Ct2q9JAj_q->!Mp41 zBaZ_@Zjtf_An_j{B>oW2+>p3%6O`enIU{A=kr|5Nc-^DsZ416Uvc0SG_<0+GPz*^*gaThm{CAIQ!?1)l6GFMeJA z^!e`2-mci&`Q+)Yi1&%jf}o{d7dygpPsC7pqHhh9u$-RNm4W5#i{L<|sY74&_=-pS z=$gj~8&Q5Z}$eNX{0h(;(hKg(z#^;S^#s$zBzn>MKt< zUFFBM*tB}pLiP0z1+%=eqMxg%P15Vqqd3(X+L1NoNuLVpx?YcK-|?i=Jy3p4$Z-q1 zF4glih+FHqb~A9rz;dEyI=&THt|Qc`>V|>pUD?1IqooVsO}2*0ddUrX8RtySHKCJb zz9MImJjvXr$~kVznq}luQ|747PH1nKR=2Bg?ZW?EAYoF`Kh28@17Ale0+A?@FO}I%ys_BhJ8&{Uf&ZmRDExQ9L4eUgGEN zsYdXgYzSPq5M00dLm3>1%XR17RPoB~T=~P*Srz9hv|Id|d;NSNs`9xR>Dx5v^V68B zGVjT%{JA=-AIkyFCPQg?G-PQGj;{cM6ZRw}mK`??qWI;_C_MSvlhrpaAlpvuDOEK} zPQ#l{ODD5I#*SoCRRUMMpyG&#x>Ra$;yNEBSE zEqn1O=f0RI@#H{VDlWbVeI^4HShf5G6v)6rR~$T+?Hvzlg)*x*tl>o3zIKso}~{tli|U36CAu5pMmGJ zxCcA2LYgZ1h*PNY7ks_+pGFTX5P$##AOHafKmY;|fB*y_009WhpMaq+=q7*vH%h;0 zr9Vr*(;F5DKmY;|fB*y_009U<00Izz00eGS;9bL5-R8eexW9FOyT0{7ed~c}J$n3r z9uG?k#(FuqxBsy5eq*bm8+UipKgxJfX@{w27corx>sMJKIUZ=k>sC-kPHW{VA zwbH+(f9MSh1Rwwb2tWV=5P$##AOHafKmY=7pTMHAs`GCKM$uT;lOG5cipJf1`rAPC z5B%@EeGNm6ApijgKmY;|fB*y_009U<00I!Wz5w60uX=z1Rwwb2tWV=5P$## zATa*|xc@)@eT)`D00Izz00bZa0SG_<0uX=z1aSW!F#rJwKmY;|fB*y_009U<00I!0 ge*xV8pZ`8a3n2gj2tWV=5P$##AOHafKmY>&1E&it$^ZZW literal 0 HcmV?d00001 diff --git a/party/__init__.py b/party/__init__.py new file mode 100644 index 0000000..fc66062 --- /dev/null +++ b/party/__init__.py @@ -0,0 +1,4 @@ +from flask import Flask + +app = Flask(__name__, + template_folder='templates') diff --git a/party/main.py b/party/main.py new file mode 100644 index 0000000..e69de29 diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..e69de29 diff --git a/test/__init__.py b/test/__init__.py new file mode 100644 index 0000000..80d6ec7 --- /dev/null +++ b/test/__init__.py @@ -0,0 +1,8 @@ +import pytest +from party import app + +@pytest.fixture +def client(): + #app.config['TESTING'] = True + client = app.test_client() + yield client diff --git a/test/test_server.py b/test/test_server.py new file mode 100644 index 0000000..ea99b78 --- /dev/null +++ b/test/test_server.py @@ -0,0 +1,23 @@ +from test import client + +def test_api(client): + endpoints = [("/api", "GET"), + ("/api/mate", "GET"), + ("/api/mate/status", "GET"), + ("/api/mate/trinken", "POST"), + ("/api/chat/", "GET"), + ("/api/chat/messages/:count", "GET"), + ("/api/chat/new_message", "POST"), + ("/api/music", "GET"), + ("/api/music/skip", "POST"), + ("/api/music/queue", "GET"), + ("/api/music/add_song", "POST") + ] + response = client.get('/api') + + for endpoint in endpoints: + if endpoint[1] == "GET": + response = client.get(endpoint[0]) + elif endpoint[1] == "POST": + response = client.post(endpoint[0]) + assert response.status_code == 200