Skip to content

Commit 0df63bd

Browse files
committed
resolved comments
1 parent 7e7523e commit 0df63bd

File tree

4 files changed

+31
-50
lines changed

4 files changed

+31
-50
lines changed

backend/app/crud/banlist.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from datetime import datetime
21
from typing import List, Optional
32
from uuid import UUID
43

@@ -10,8 +9,9 @@
109
from app.schemas.banlist import BanListCreate, BanListUpdate
1110
from app.utils import now
1211

12+
1313
class BanListCrud:
14-
def create(
14+
def create(
1515
self,
1616
session: Session,
1717
data: BanListCreate,
@@ -41,8 +41,8 @@ def create(
4141
return obj
4242

4343
def get(
44-
self,
45-
session: Session,
44+
self,
45+
session: Session,
4646
id: UUID,
4747
organization_id: int,
4848
project_id: int
@@ -114,16 +114,17 @@ def delete(self, session: Session, obj: BanList):
114114
session.rollback()
115115
raise
116116

117-
def check_owner(self, obj, organization_id, project_id):
118-
is_owner = (
119-
obj.organization_id == organization_id
120-
and obj.project_id == project_id
121-
)
122-
123-
if not is_owner:
124-
raise HTTPException(
125-
status_code=403,
126-
detail="You do not have permission to access this resource."
117+
def check_owner(self, obj: BanList, organization_id: int, project_id: int) -> None:
118+
is_owner = (
119+
obj.organization_id == organization_id
120+
and obj.project_id == project_id
127121
)
128122

129-
banlist_crud = BanListCrud()
123+
if not is_owner:
124+
raise HTTPException(
125+
status_code=403,
126+
detail="You do not have permission to access this resource."
127+
)
128+
129+
130+
banlist_crud = BanListCrud()

backend/app/tests/conftest.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,21 @@ def seed_db():
9696
seed_test_data(session)
9797
yield
9898

99+
@pytest.fixture
100+
def clear_database():
101+
"""Clear key config tables before and after each test."""
102+
with Session(test_engine) as session:
103+
session.exec(delete(BanList))
104+
session.exec(delete(ValidatorConfig))
105+
session.commit()
106+
107+
yield
108+
109+
with Session(test_engine) as session:
110+
session.exec(delete(BanList))
111+
session.exec(delete(ValidatorConfig))
112+
session.commit()
113+
99114
@pytest.fixture(scope="function")
100115
def client():
101116
with TestClient(app) as c:

backend/app/tests/test_banlists_integration.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
import uuid
22
import pytest
3-
from sqlmodel import Session, delete
4-
5-
from app.core.db import engine
6-
from app.models.config.banlist import BanList
73
from app.tests.seed_data import (
84
BANLIST_INTEGRATION_ORGANIZATION_ID,
95
BANLIST_INTEGRATION_PROJECT_ID,
@@ -20,19 +16,6 @@
2016
)
2117

2218

23-
@pytest.fixture
24-
def clear_database():
25-
with Session(engine) as session:
26-
session.exec(delete(BanList))
27-
session.commit()
28-
29-
yield
30-
31-
with Session(engine) as session:
32-
session.exec(delete(BanList))
33-
session.commit()
34-
35-
3619
class BaseBanListTest:
3720

3821
def create(self, client, payload_key="minimal", **kwargs):

backend/app/tests/test_validator_configs_integration.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
import uuid
22

33
import pytest
4-
from sqlmodel import Session, delete
5-
6-
from app.core.db import engine
7-
from app.models.config.validator_config import ValidatorConfig
84
from app.tests.seed_data import (
95
VALIDATOR_INTEGRATION_ORGANIZATION_ID,
106
VALIDATOR_INTEGRATION_PROJECT_ID,
@@ -20,20 +16,6 @@
2016
)
2117

2218

23-
@pytest.fixture
24-
def clear_database():
25-
"""Clear ValidatorConfig table before and after each test."""
26-
with Session(engine) as session:
27-
session.exec(delete(ValidatorConfig))
28-
session.commit()
29-
30-
yield
31-
32-
with Session(engine) as session:
33-
session.exec(delete(ValidatorConfig))
34-
session.commit()
35-
36-
3719
class BaseValidatorTest:
3820
"""Base class with helper methods for validator tests."""
3921

0 commit comments

Comments
 (0)