Skip to content

Commit 666cc14

Browse files
committed
Update README.md
Update README.md
1 parent b7ac610 commit 666cc14

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
# app.py
22
```python
33
from flask import Flask, request, jsonify
4-
import db
4+
from integration_test.db import insert_user
55

6-
app = Flask(__name__)
6+
flask_app = Flask(__name__)
77

8-
@app.route("/register", methods=["POST"])
8+
@flask_app.route("/register", methods=["POST"])
99
def register():
1010
data = request.get_json()
1111
username = data.get("username")
1212
if not username:
1313
return jsonify({"error": "Username required"}), 400
14-
db.insert_user(username)
14+
insert_user(username)
1515
return jsonify({"message": f"User {username} registered"}), 201
1616
```
1717

@@ -42,27 +42,25 @@ def get_users():
4242
users = [row[0] for row in db_connection_cursor.fetchall()]
4343
db_connection.close()
4444
return users
45-
4645
```
4746

4847
# test_integration.py
4948

5049
```python
5150
import pytest
52-
from integration_test import app
53-
import db
51+
52+
from integration_test.db import (init_db, get_users)
53+
from integration_test.app import (flask_app)
5454

5555

5656
@pytest.fixture(scope="module")
5757
def client():
58-
db.init_db()
59-
with app.flask_app.test_client() as client:
58+
init_db()
59+
with flask_app.test_client() as client:
6060
yield client
6161

62-
6362
def test_register_user(client):
6463
response = client.post("/register", json={"username": "Alice"})
6564
assert response.status_code == 201
66-
assert "Alice" in db.get_users()
67-
65+
assert "Alice" in get_users()
6866
```

0 commit comments

Comments
 (0)