Skip to content

Commit be46496

Browse files
Pylint issue fix
1 parent d94f66e commit be46496

5 files changed

Lines changed: 97 additions & 87 deletions

File tree

src/backend/common/database/database_base.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,54 +17,54 @@ class DatabaseBase(ABC):
1717
@abstractmethod
1818
async def initialize_cosmos(self) -> None:
1919
"""Initialize the cosmosdb client and create container if needed"""
20-
pass # pragma: no cover
20+
pass # pragma: no cover
2121

2222
@abstractmethod
2323
async def create_batch(self, user_id: str, batch_id: uuid.UUID) -> BatchRecord:
2424
"""Create a new conversion batch"""
25-
pass # pragma: no cover
25+
pass # pragma: no cover
2626

2727
@abstractmethod
2828
async def get_file_logs(self, file_id: str) -> Dict:
2929
"""Retrieve all logs for a file"""
30-
pass # pragma: no cover
30+
pass # pragma: no cover
3131

3232
@abstractmethod
3333
async def get_batch_from_id(self, batch_id: str) -> Dict:
3434
"""Retrieve all logs for a file"""
35-
pass # pragma: no cover
35+
pass # pragma: no cover
3636

3737
@abstractmethod
3838
async def get_batch_files(self, batch_id: str) -> List[Dict]:
3939
"""Retrieve all files for a batch"""
40-
pass # pragma: no cover
40+
pass # pragma: no cover
4141

4242
@abstractmethod
4343
async def delete_file_logs(self, file_id: str) -> None:
4444
"""Delete all logs for a file"""
45-
pass # pragma: no cover
45+
pass # pragma: no cover
4646

4747
@abstractmethod
4848
async def get_user_batches(self, user_id: str) -> Dict:
4949
"""Retrieve all batches for a user"""
50-
pass # pragma: no cover
50+
pass # pragma: no cover
5151

5252
@abstractmethod
5353
async def add_file(
5454
self, batch_id: uuid.UUID, file_id: uuid.UUID, file_name: str, storage_path: str
5555
) -> FileRecord:
5656
"""Add a file entry to the database"""
57-
pass # pragma: no cover
57+
pass # pragma: no cover
5858

5959
@abstractmethod
6060
async def get_batch(self, user_id: str, batch_id: str) -> Optional[Dict]:
6161
"""Retrieve a batch and its associated files"""
62-
pass # pragma: no cover
62+
pass # pragma: no cover
6363

6464
@abstractmethod
6565
async def get_file(self, file_id: str) -> Optional[Dict]:
6666
"""Retrieve a file entry along with its logs"""
67-
pass # pragma: no cover
67+
pass # pragma: no cover
6868

6969
@abstractmethod
7070
async def add_file_log(
@@ -77,39 +77,39 @@ async def add_file_log(
7777
author_role: AuthorRole,
7878
) -> None:
7979
"""Log a file status update"""
80-
pass # pragma: no cover
80+
pass # pragma: no cover
8181

8282
@abstractmethod
8383
async def update_file(self, file_record: FileRecord) -> None:
84-
"""update file record"""
85-
pass # pragma: no cover
84+
"""Update file record"""
85+
pass # pragma: no cover
8686

8787
@abstractmethod
8888
async def update_batch(self, batch_record: BatchRecord) -> BatchRecord:
8989
"""Update a batch record"""
90-
pass # pragma: no cover
90+
pass # pragma: no cover
9191

9292
@abstractmethod
9393
async def delete_all(self, user_id: str) -> None:
9494
"""Delete all batches, files, and logs for a user"""
95-
pass # pragma: no cover
95+
pass # pragma: no cover
9696

9797
@abstractmethod
9898
async def delete_batch(self, user_id: str, batch_id: str) -> None:
9999
"""Delete a batch along with its files and logs"""
100-
pass # pragma: no cover
100+
pass # pragma: no cover
101101

102102
@abstractmethod
103103
async def delete_file(self, user_id: str, batch_id: str, file_id: str) -> None:
104104
"""Delete a file and its logs, and update batch file count"""
105-
pass # pragma: no cover
105+
pass # pragma: no cover
106106

107107
@abstractmethod
108108
async def get_batch_history(self, user_id: str, batch_id: str) -> List[Dict]:
109109
"""Retrieve all logs for a batch"""
110-
pass # pragma: no cover
110+
pass # pragma: no cover
111111

112112
@abstractmethod
113113
async def close(self) -> None:
114114
"""Close database connection"""
115-
pass # pragma: no cover
115+
pass # pragma: no cover

src/tests/backend/common/config/config_test.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
import os
2-
import sys
31
import pytest
4-
5-
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../../../..', 'backend')))
6-
2+
3+
74
@pytest.fixture(autouse=True)
85
def clear_env(monkeypatch):
96
# Clear environment variables that might affect tests.
@@ -21,7 +18,8 @@ def clear_env(monkeypatch):
2118
]
2219
for key in keys:
2320
monkeypatch.delenv(key, raising=False)
24-
21+
22+
2523
def test_config_initialization(monkeypatch):
2624
# Set the full configuration environment variables.
2725
monkeypatch.setenv("AZURE_TENANT_ID", "test-tenant-id")
@@ -34,11 +32,11 @@ def test_config_initialization(monkeypatch):
3432
monkeypatch.setenv("COSMOSDB_LOG_CONTAINER", "test-log-container")
3533
monkeypatch.setenv("AZURE_BLOB_CONTAINER_NAME", "test-blob-container-name")
3634
monkeypatch.setenv("AZURE_BLOB_ACCOUNT_NAME", "test-blob-account-name")
37-
35+
3836
# Local import to avoid triggering circular imports during module collection.
3937
from common.config.config import Config
4038
config = Config()
41-
39+
4240
assert config.azure_tenant_id == "test-tenant-id"
4341
assert config.azure_client_id == "test-client-id"
4442
assert config.azure_client_secret == "test-client-secret"
@@ -49,22 +47,21 @@ def test_config_initialization(monkeypatch):
4947
assert config.cosmosdb_log_container == "test-log-container"
5048
assert config.azure_blob_container_name == "test-blob-container-name"
5149
assert config.azure_blob_account_name == "test-blob-account-name"
52-
50+
51+
5352
def test_cosmosdb_config_initialization(monkeypatch):
5453
# Set only cosmosdb-related environment variables.
5554
monkeypatch.setenv("COSMOSDB_ENDPOINT", "test-cosmosdb-endpoint")
5655
monkeypatch.setenv("COSMOSDB_DATABASE", "test-database")
5756
monkeypatch.setenv("COSMOSDB_BATCH_CONTAINER", "test-batch-container")
5857
monkeypatch.setenv("COSMOSDB_FILE_CONTAINER", "test-file-container")
5958
monkeypatch.setenv("COSMOSDB_LOG_CONTAINER", "test-log-container")
60-
59+
6160
from common.config.config import Config
6261
config = Config()
63-
62+
6463
assert config.cosmosdb_endpoint == "test-cosmosdb-endpoint"
6564
assert config.cosmosdb_database == "test-database"
6665
assert config.cosmosdb_batch_container == "test-batch-container"
6766
assert config.cosmosdb_file_container == "test-file-container"
6867
assert config.cosmosdb_log_container == "test-log-container"
69-
70-
Lines changed: 54 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,66 @@
1-
import asyncio
21
import uuid
3-
import pytest
4-
import os
5-
import sys
6-
from datetime import datetime
72
from enum import Enum
8-
9-
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../../../../backend')))
10-
3+
4+
115
from common.database.database_base import DatabaseBase
12-
from common.models.api import BatchRecord, FileRecord, ProcessStatus
13-
6+
from common.models.api import ProcessStatus
7+
8+
import pytest
9+
10+
1411
# Allow instantiation of the abstract base class by clearing its abstract methods.
1512
DatabaseBase.__abstractmethods__ = set()
16-
13+
14+
1715
@pytest.fixture
1816
def db_instance():
1917
# Create a concrete implementation of DatabaseBase using async methods.
2018
class ConcreteDatabase(DatabaseBase):
2119
async def create_batch(self, user_id, batch_id):
2220
pass
23-
21+
2422
async def get_file_logs(self, file_id):
2523
pass
26-
24+
2725
async def get_batch_files(self, user_id, batch_id):
2826
pass
29-
27+
3028
async def delete_file_logs(self, file_id):
3129
pass
32-
30+
3331
async def get_user_batches(self, user_id):
3432
pass
35-
33+
3634
async def add_file(self, batch_id, file_id, file_name, file_path):
3735
pass
38-
36+
3937
async def get_batch(self, user_id, batch_id):
4038
pass
41-
39+
4240
async def get_file(self, file_id):
4341
pass
44-
42+
4543
async def log_file_status(self, file_id, status, description, log_type):
4644
pass
47-
45+
4846
async def log_batch_status(self, batch_id, status, file_count):
4947
pass
50-
48+
5149
async def delete_all(self, user_id):
5250
pass
53-
51+
5452
async def delete_batch(self, user_id, batch_id):
5553
pass
56-
54+
5755
async def delete_file(self, user_id, batch_id, file_id):
5856
pass
59-
57+
6058
async def close(self):
6159
pass
62-
60+
6361
return ConcreteDatabase()
64-
62+
63+
6564
def get_dummy_status():
6665
"""
6766
Try to use a specific ProcessStatus value (e.g. PROCESSING).
@@ -76,76 +75,90 @@ def get_dummy_status():
7675
# If the enum is empty, create a dummy one.
7776
DummyStatus = Enum("DummyStatus", {"DUMMY": "dummy"})
7877
return DummyStatus.DUMMY
79-
78+
79+
8080
@pytest.mark.asyncio
8181
async def test_create_batch(db_instance):
8282
result = await db_instance.create_batch("user1", uuid.uuid4())
8383
# Since the method is implemented as pass, result is None.
8484
assert result is None
85-
85+
86+
8687
@pytest.mark.asyncio
8788
async def test_get_file_logs(db_instance):
8889
result = await db_instance.get_file_logs("file1")
8990
assert result is None
90-
91+
92+
9193
@pytest.mark.asyncio
9294
async def test_get_batch_files(db_instance):
9395
result = await db_instance.get_batch_files("user1", "batch1")
9496
assert result is None
95-
97+
98+
9699
@pytest.mark.asyncio
97100
async def test_delete_file_logs(db_instance):
98101
result = await db_instance.delete_file_logs("file1")
99102
assert result is None
100-
103+
104+
101105
@pytest.mark.asyncio
102106
async def test_get_user_batches(db_instance):
103107
result = await db_instance.get_user_batches("user1")
104108
assert result is None
105-
109+
110+
106111
@pytest.mark.asyncio
107112
async def test_add_file(db_instance):
108113
result = await db_instance.add_file(uuid.uuid4(), uuid.uuid4(), "test.txt", "/dummy/path")
109114
assert result is None
110-
115+
116+
111117
@pytest.mark.asyncio
112118
async def test_get_batch(db_instance):
113119
result = await db_instance.get_batch("user1", "batch1")
114120
assert result is None
115-
121+
122+
116123
@pytest.mark.asyncio
117124
async def test_get_file(db_instance):
118125
result = await db_instance.get_file("file1")
119126
assert result is None
120-
127+
128+
121129
@pytest.mark.asyncio
122130
async def test_log_file_status(db_instance):
123131
# Using ProcessStatus.COMPLETED as an example.
124132
result = await db_instance.log_file_status("file1", ProcessStatus.COMPLETED, "desc", "log_type")
125133
assert result is None
126-
134+
135+
127136
@pytest.mark.asyncio
128137
async def test_log_batch_status(db_instance):
129138
dummy_status = get_dummy_status()
130139
result = await db_instance.log_batch_status("batch1", dummy_status, 5)
131140
assert result is None
132-
141+
142+
133143
@pytest.mark.asyncio
134144
async def test_delete_all(db_instance):
135145
result = await db_instance.delete_all("user1")
136146
assert result is None
137-
147+
148+
138149
@pytest.mark.asyncio
139150
async def test_delete_batch(db_instance):
140151
result = await db_instance.delete_batch("user1", "batch1")
141152
assert result is None
142-
153+
154+
143155
@pytest.mark.asyncio
144156
async def test_delete_file(db_instance):
145157
result = await db_instance.delete_file("user1", "batch1", "file1")
146158
assert result is None
147-
159+
160+
148161
@pytest.mark.asyncio
149162
async def test_close(db_instance):
150163
result = await db_instance.close()
151-
assert result is None
164+
assert result is None

0 commit comments

Comments
 (0)