Skip to content

Commit cfb9442

Browse files
committed
Format imports with isort and reformat with Black
1 parent 076f94b commit cfb9442

38 files changed

Lines changed: 129 additions & 93 deletions

Tests/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
"""Pytest configuration and shared fixtures for jsweb tests."""
22

3-
import sys
4-
from pathlib import Path
53
from io import BytesIO
4+
from pathlib import Path
5+
import sys
66

77
import pytest
88

Tests/script_install_required_modules_for_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import subprocess
2-
import sys
31
import importlib
42
import os
3+
import subprocess
4+
import sys
55

66

77
def install_module(module_name):

Tests/test_authentication.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class User(Base):
3232
def test_user_authentication():
3333
"""Test user authentication workflow."""
3434
try:
35-
from jsweb.security import hash_password, check_password
35+
from jsweb.security import check_password, hash_password
3636

3737
password = "secure_password_123"
3838
hashed = hash_password(password)
@@ -234,9 +234,10 @@ def logout(self, username):
234234
def test_jwt_token_support():
235235
"""Test JWT token support (if available)."""
236236
try:
237-
import jwt
238237
from datetime import datetime, timedelta
239238

239+
import jwt
240+
240241
secret = "test-secret"
241242
payload = {
242243
"user_id": 1,
@@ -282,7 +283,7 @@ def remaining_time(self):
282283
def test_password_reset_flow():
283284
"""Test password reset workflow."""
284285
try:
285-
from jsweb.security import hash_password, generate_secure_token
286+
from jsweb.security import generate_secure_token, hash_password
286287

287288
# Step 1: Generate reset token
288289
reset_token = generate_secure_token()

Tests/test_database.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def test_database_connection():
2020
@pytest.mark.database
2121
def test_sqlalchemy_import():
2222
"""Test that SQLAlchemy is available."""
23-
from sqlalchemy import create_engine, Column, Integer, String
23+
from sqlalchemy import Column, Integer, String, create_engine
2424

2525
assert create_engine is not None
2626
assert Column is not None
@@ -53,7 +53,7 @@ class User(Base):
5353
def test_model_relationships():
5454
"""Test model relationship definitions."""
5555
try:
56-
from sqlalchemy import Column, Integer, String, ForeignKey
56+
from sqlalchemy import Column, ForeignKey, Integer, String
5757
from sqlalchemy.orm import declarative_base, relationship
5858

5959
Base = declarative_base()
@@ -99,7 +99,7 @@ def test_database_session():
9999
def test_model_validation():
100100
"""Test model field validation."""
101101
try:
102-
from sqlalchemy import Column, Integer, String, CheckConstraint
102+
from sqlalchemy import CheckConstraint, Column, Integer, String
103103
from sqlalchemy.orm import declarative_base
104104

105105
Base = declarative_base()
@@ -158,7 +158,7 @@ class User(BaseModel):
158158
def test_model_indexes():
159159
"""Test model field indexing."""
160160
try:
161-
from sqlalchemy import Column, Integer, String, Index
161+
from sqlalchemy import Column, Index, Integer, String
162162
from sqlalchemy.orm import declarative_base
163163

164164
Base = declarative_base()
@@ -199,10 +199,11 @@ class User(Base):
199199
def test_model_default_values():
200200
"""Test model default values."""
201201
try:
202-
from sqlalchemy import Column, Integer, String, DateTime
203-
from sqlalchemy.orm import declarative_base
204202
from datetime import datetime
205203

204+
from sqlalchemy import Column, DateTime, Integer, String
205+
from sqlalchemy.orm import declarative_base
206+
206207
Base = declarative_base()
207208

208209
class Post(Base):
@@ -265,10 +266,11 @@ def __repr__(self):
265266
def test_enum_field():
266267
"""Test enum field type."""
267268
try:
268-
from sqlalchemy import Column, Integer, String, Enum
269-
from sqlalchemy.orm import declarative_base
270269
import enum
271270

271+
from sqlalchemy import Column, Enum, Integer, String
272+
from sqlalchemy.orm import declarative_base
273+
272274
Base = declarative_base()
273275

274276
class UserRole(enum.Enum):
@@ -291,7 +293,7 @@ class User(Base):
291293
def test_json_field():
292294
"""Test JSON field type."""
293295
try:
294-
from sqlalchemy import Column, Integer, JSON
296+
from sqlalchemy import JSON, Column, Integer
295297
from sqlalchemy.orm import declarative_base
296298

297299
Base = declarative_base()
@@ -331,7 +333,7 @@ class BlogPost(Base):
331333
def test_many_to_many_relationship():
332334
"""Test many-to-many relationship."""
333335
try:
334-
from sqlalchemy import Column, Integer, String, ForeignKey, Table
336+
from sqlalchemy import Column, ForeignKey, Integer, String, Table
335337
from sqlalchemy.orm import declarative_base, relationship
336338

337339
Base = declarative_base()

Tests/test_features.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
"""Tests for new JsWeb features (JSON parsing, file uploads, validators)."""
22

3+
from io import BytesIO
34
import json
5+
46
import pytest
5-
from io import BytesIO
67

78

89
@pytest.mark.unit
910
def test_import_new_features():
1011
"""Test that all new features can be imported."""
11-
from jsweb import UploadedFile, FileField, FileRequired, FileAllowed, FileSize
12+
from jsweb import FileAllowed, FileField, FileRequired, FileSize, UploadedFile
1213

1314
assert UploadedFile is not None
1415
assert FileField is not None
@@ -86,8 +87,8 @@ async def receive():
8687
@pytest.mark.unit
8788
def test_filefield_creation():
8889
"""Test FileField creation in forms."""
89-
from jsweb.forms import Form, FileField
90-
from jsweb.validators import FileRequired, FileAllowed, FileSize
90+
from jsweb.forms import FileField, Form
91+
from jsweb.validators import FileAllowed, FileRequired, FileSize
9192

9293
class TestForm(Form):
9394
upload = FileField(

Tests/test_forms.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
"""Tests for JsWeb forms and validation system."""
22

3-
import pytest
43
from io import BytesIO
54

5+
import pytest
6+
67

78
@pytest.mark.unit
89
@pytest.mark.forms
@@ -171,7 +172,7 @@ def __init__(self, data):
171172
@pytest.mark.forms
172173
def test_form_multiple_fields():
173174
"""Test form with multiple different field types."""
174-
from jsweb.forms import Form, StringField, IntegerField, BooleanField
175+
from jsweb.forms import BooleanField, Form, IntegerField, StringField
175176

176177
class ProfileForm(Form):
177178
name = StringField("Name")
@@ -318,8 +319,8 @@ class RequiredForm(Form):
318319
@pytest.mark.forms
319320
def test_file_field_validators():
320321
"""Test FileField with validators."""
321-
from jsweb.forms import Form, FileField
322-
from jsweb.validators import FileRequired, FileAllowed, FileSize
322+
from jsweb.forms import FileField, Form
323+
from jsweb.validators import FileAllowed, FileRequired, FileSize
323324

324325
class UploadForm(Form):
325326
document = FileField(

Tests/test_performance.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
"""Framework comparison and performance benchmarking tests."""
22

3-
import pytest
43
import time
54

5+
import pytest
6+
67

78
@pytest.mark.slow
89
@pytest.mark.integration
@@ -162,9 +163,10 @@ def test_flask_routing_performance():
162163
@pytest.mark.unit
163164
def test_routing_comparison_jsweb_vs_alternatives():
164165
"""Test and compare JsWeb routing against simple alternatives."""
165-
from jsweb.routing import Router
166166
import re
167167

168+
from jsweb.routing import Router
169+
168170
# JsWeb router
169171
jsweb_router = Router()
170172

Tests/test_request_response.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
"""Tests for JsWeb request and response handling."""
22

3-
import pytest
4-
import json
53
from io import BytesIO
4+
import json
5+
6+
import pytest
67

78

89
@pytest.mark.unit
@@ -67,9 +68,10 @@ class config:
6768
@pytest.mark.asyncio
6869
async def test_request_json_parsing():
6970
"""Test JSON request body parsing."""
70-
from jsweb.request import Request
7171
import json
7272

73+
from jsweb.request import Request
74+
7375
class FakeApp:
7476
class config:
7577
pass
@@ -239,9 +241,10 @@ def test_response_json():
239241
assert response is not None
240242
except (ImportError, AttributeError):
241243
# Try alternative
242-
from jsweb.response import Response
243244
import json
244245

246+
from jsweb.response import Response
247+
245248
data = {"message": "success", "code": 200}
246249
json_str = json.dumps(data)
247250
response = Response(json_str)

Tests/test_routing.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Tests for jsweb routing system."""
22

33
import pytest
4+
45
from jsweb.routing import Router
56

67

Tests/test_security.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def test_csrf_token_validation():
3838
def test_password_hashing():
3939
"""Test password hashing functionality."""
4040
try:
41-
from jsweb.security import hash_password, check_password
41+
from jsweb.security import check_password, hash_password
4242

4343
password = "mySecurePassword123!"
4444
hashed = hash_password(password)
@@ -71,7 +71,7 @@ def test_password_hash_unique():
7171
def test_password_verification_fails_for_wrong_password():
7272
"""Test that password verification fails for incorrect password."""
7373
try:
74-
from jsweb.security import hash_password, check_password
74+
from jsweb.security import check_password, hash_password
7575

7676
password = "correctpassword"
7777
wrong_password = "wrongpassword"
@@ -106,9 +106,10 @@ def test_secure_random_generation():
106106
def test_token_expiration():
107107
"""Test token expiration functionality."""
108108
try:
109-
from jsweb.security import generate_token_with_expiry, verify_token
110109
import time
111110

111+
from jsweb.security import generate_token_with_expiry, verify_token
112+
112113
token = generate_token_with_expiry(expiry_seconds=1)
113114
assert token is not None
114115

0 commit comments

Comments
 (0)