Spaces:
Runtime error
Runtime error
NMPhap
commited on
Commit
•
dc66a7c
1
Parent(s):
0890b20
<CI>: add git action to workflow for testing ci
Browse files- app/__init__.py +8 -5
- app/routers/friend_request.py +0 -1
- app/routers/test_friend_request.py +36 -0
- app/test_main.py +14 -12
app/__init__.py
CHANGED
@@ -5,6 +5,7 @@ import logging
|
|
5 |
from dotenv import load_dotenv
|
6 |
from mmdeploy_runtime import Detector
|
7 |
from supabase import create_client, Client
|
|
|
8 |
from firebase_admin import credentials, initialize_app
|
9 |
from firebase_admin import firestore
|
10 |
from neo4j import GraphDatabase
|
@@ -26,12 +27,14 @@ key: str = os.environ.get("SUPABASE_KEY")
|
|
26 |
supabase: Client = create_client(url, key)
|
27 |
|
28 |
# LOAD FIREBASE ADMIN SDK
|
29 |
-
|
30 |
-
|
31 |
-
|
|
|
|
|
32 |
)
|
33 |
-
|
34 |
-
|
35 |
db = firestore.client()
|
36 |
|
37 |
# LOAD NEO4J DB
|
|
|
5 |
from dotenv import load_dotenv
|
6 |
from mmdeploy_runtime import Detector
|
7 |
from supabase import create_client, Client
|
8 |
+
import firebase_admin
|
9 |
from firebase_admin import credentials, initialize_app
|
10 |
from firebase_admin import firestore
|
11 |
from neo4j import GraphDatabase
|
|
|
27 |
supabase: Client = create_client(url, key)
|
28 |
|
29 |
# LOAD FIREBASE ADMIN SDK
|
30 |
+
if not firebase_admin._apps:
|
31 |
+
firebase_app = initialize_app(
|
32 |
+
credential=credentials.Certificate(
|
33 |
+
json.loads(os.environ.get("FIREBASE_CREDENTIALS"))
|
34 |
+
)
|
35 |
)
|
36 |
+
else:
|
37 |
+
firebase_app = firebase_admin._apps
|
38 |
db = firestore.client()
|
39 |
|
40 |
# LOAD NEO4J DB
|
app/routers/friend_request.py
CHANGED
@@ -7,7 +7,6 @@ from app import db
|
|
7 |
from enum import Enum
|
8 |
from app.graphdb.main import insert2PersonAndSetFriend
|
9 |
|
10 |
-
|
11 |
router = APIRouter(prefix="/friend_request", tags=["friend_request"])
|
12 |
|
13 |
|
|
|
7 |
from enum import Enum
|
8 |
from app.graphdb.main import insert2PersonAndSetFriend
|
9 |
|
|
|
10 |
router = APIRouter(prefix="/friend_request", tags=["friend_request"])
|
11 |
|
12 |
|
app/routers/test_friend_request.py
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import pytest
|
2 |
+
import json
|
3 |
+
import requests
|
4 |
+
@pytest.fixture
|
5 |
+
def token_inviter():
|
6 |
+
url = "https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key=AIzaSyArSoK9Wx9Hpe1R9ZywuLEIMVjCtHjO8Os"
|
7 |
+
|
8 |
+
payload = json.dumps({
|
9 |
+
"email": "test@gmail.com",
|
10 |
+
"password": "testing",
|
11 |
+
"returnSecureToken": True
|
12 |
+
})
|
13 |
+
headers = {
|
14 |
+
'Content-Type': 'application/json'
|
15 |
+
}
|
16 |
+
response = requests.request("POST", url, headers=headers, data=payload)
|
17 |
+
token = response.json()["idToken"]
|
18 |
+
yield token
|
19 |
+
@pytest.fixture()
|
20 |
+
def token_invitee():
|
21 |
+
url = "https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key=AIzaSyArSoK9Wx9Hpe1R9ZywuLEIMVjCtHjO8Os"
|
22 |
+
|
23 |
+
payload = json.dumps({
|
24 |
+
"email": "test2@gmail.com",
|
25 |
+
"password": "testing2",
|
26 |
+
"returnSecureToken": True
|
27 |
+
})
|
28 |
+
headers = {
|
29 |
+
'Content-Type': 'application/json'
|
30 |
+
}
|
31 |
+
response = requests.request("POST", url, headers=headers, data=payload)
|
32 |
+
token = response.json()["idToken"]
|
33 |
+
yield token
|
34 |
+
class testFriendRequest():
|
35 |
+
def test_get_qr():
|
36 |
+
|
app/test_main.py
CHANGED
@@ -8,7 +8,7 @@ import site
|
|
8 |
import shutil
|
9 |
from fastapi.routing import APIRoute
|
10 |
from app import firebase_app
|
11 |
-
|
12 |
def get_site_packages():
|
13 |
# Get the list of directories
|
14 |
site_packages_dirs = site.getsitepackages()
|
@@ -27,23 +27,25 @@ def endpoints():
|
|
27 |
for route in app.routes:
|
28 |
if isinstance(route, APIRoute):
|
29 |
endpoints.append(route.path)
|
30 |
-
return endpoints
|
31 |
-
@pytest.fixture(autouse=True)
|
32 |
-
def modify_mmcv_image():
|
33 |
-
site_packages_path = get_site_packages()
|
34 |
-
dirList = os.listdir(site_packages_path)
|
35 |
-
if "mmcv" in dirList:
|
36 |
-
shutil.copyfile("libs/image.py", os.path.join(site_packages_path, "mmcv/visualization/image.py"))
|
37 |
-
else:
|
38 |
-
pytest.exit('Error: Cannot modified mmcv.Image')
|
39 |
-
|
40 |
@pytest.fixture
|
41 |
def client():
|
42 |
client = TestClient(app, "http://0.0.0.0:3000")
|
43 |
yield client
|
44 |
@pytest.fixture
|
45 |
def token():
|
46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
yield token
|
48 |
class TestFireBaseAPI():
|
49 |
def test_get_me(self, client, token):
|
|
|
8 |
import shutil
|
9 |
from fastapi.routing import APIRoute
|
10 |
from app import firebase_app
|
11 |
+
import requests
|
12 |
def get_site_packages():
|
13 |
# Get the list of directories
|
14 |
site_packages_dirs = site.getsitepackages()
|
|
|
27 |
for route in app.routes:
|
28 |
if isinstance(route, APIRoute):
|
29 |
endpoints.append(route.path)
|
30 |
+
return endpoints
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
@pytest.fixture
|
32 |
def client():
|
33 |
client = TestClient(app, "http://0.0.0.0:3000")
|
34 |
yield client
|
35 |
@pytest.fixture
|
36 |
def token():
|
37 |
+
url = "https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key=AIzaSyArSoK9Wx9Hpe1R9ZywuLEIMVjCtHjO8Os"
|
38 |
+
|
39 |
+
payload = json.dumps({
|
40 |
+
"email": "test@gmail.com",
|
41 |
+
"password": "testing",
|
42 |
+
"returnSecureToken": True
|
43 |
+
})
|
44 |
+
headers = {
|
45 |
+
'Content-Type': 'application/json'
|
46 |
+
}
|
47 |
+
response = requests.request("POST", url, headers=headers, data=payload)
|
48 |
+
token = response.json()["idToken"]
|
49 |
yield token
|
50 |
class TestFireBaseAPI():
|
51 |
def test_get_me(self, client, token):
|