Skip to content

Commit 4655a9e

Browse files
committed
Merge branch 'feat/githubFolder' of https://github.com/Geode-solutions/OpenGeodeWeb-Microservice into feat/githubFolder
2 parents fefecf1 + 05d6194 commit 4655a9e

6 files changed

Lines changed: 12 additions & 0 deletions

File tree

src/opengeodeweb_microservice/app_config.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import os
22
from .database.connection import DATABASE_FILENAME
33

4+
45
class Config:
56
pass
67

8+
79
class ProdConfig(Config):
810
DATA_FOLDER_PATH = "/data"
911
SQLALCHEMY_DATABASE_URI = f"sqlite:///{os.path.abspath(

src/opengeodeweb_microservice/database/connection.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
DATABASE_FILENAME = "project.db"
99
db: Optional[SQLAlchemy] = None
1010

11+
1112
def init_database(app: Flask, db_filename: str = DATABASE_FILENAME) -> SQLAlchemy:
1213
global db
1314
if db is None:
@@ -17,9 +18,11 @@ def init_database(app: Flask, db_filename: str = DATABASE_FILENAME) -> SQLAlchem
1718
db.create_all()
1819
return db
1920

21+
2022
def get_database() -> Optional[SQLAlchemy]:
2123
return db
2224

25+
2326
def get_session():
2427
return db.session if db else None
2528

src/opengeodeweb_microservice/microservice/data.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from .base import Base
55
import uuid
66

7+
78
class Data(Base):
89
__tablename__ = "datas"
910

tests/conftest.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from src.opengeodeweb_microservice.database.connection import init_database, get_session
55
from src.opengeodeweb_microservice.microservice.data import Data
66

7+
78
@pytest.fixture(scope="session")
89
def app():
910
app = Flask(__name__)
@@ -31,11 +32,13 @@ def _cleanup_database():
3132
except PermissionError:
3233
pass
3334

35+
3436
@pytest.fixture
3537
def app_context(app):
3638
with app.app_context():
3739
yield
3840

41+
3942
@pytest.fixture
4043
def clean_database(app_context):
4144
session = get_session()

tests/test_connection.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
)
55
from src.opengeodeweb_microservice.microservice.data import Data
66

7+
78
def test_database_connection_basic(app_context):
89
session = get_session()
910
assert session is not None

tests/test_database.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from src.opengeodeweb_microservice.database.connection import get_session
22
from src.opengeodeweb_microservice.microservice.data import Data
33

4+
45
def test_data_crud_operations():
56
data = Data.create(geode_object="test_object", input_file="test.txt")
67
assert data.id is not None
@@ -12,6 +13,7 @@ def test_data_crud_operations():
1213
non_existent = Data.get("fake_id")
1314
assert non_existent is None
1415

16+
1517
def test_data_with_additional_files():
1618
files = ["file1.txt", "file2.txt"]
1719
data = Data.create(geode_object="test_files", additional_files=files)

0 commit comments

Comments
 (0)