Spaces:
Runtime error
Runtime error
Commit ·
d454ab0
1
Parent(s): afc114b
Worked with scope what is it and what does it do in test/database.py
Browse filesFiles changed (2)
11 unmodified lines121314151617183 unmodified lines2223242526272811 unmodified linesengine = create_engine(SQLALCHEMY_DATABASE_URL)TestingSessionMaker = sessionmaker(autoflush=False, autocommit=False, bind=engine)@pytest.fixturedef session():Base.metadata.drop_all(bind=engine)Base.metadata.create_all(bind=engine)3 unmodified linesfinally:db.close()@pytest.fixturedef client(session):def override_get_db():try:11 unmodified lines121314151617183 unmodified lines2223242526272811 unmodified linesengine = create_engine(SQLALCHEMY_DATABASE_URL)TestingSessionMaker = sessionmaker(autoflush=False, autocommit=False, bind=engine)@pytest.fixture(scope="module")def session():Base.metadata.drop_all(bind=engine)Base.metadata.create_all(bind=engine)3 unmodified linesfinally:db.close()@pytest.fixture(scope="module")def client(session):def override_get_db():try:
9 unmodified lines101112139 unmodified linesresponse = client.post("/users/", json={"email": "abdullah@gmail.com", "password": "abdullah1234"})new_user = user.UserResponse(**response.json())assert response.status_code == 201assert new_user.email == "abdullah@gmail.com"9 unmodified lines10111213141516179 unmodified linesresponse = client.post("/users/", json={"email": "abdullah@gmail.com", "password": "abdullah1234"})new_user = user.UserResponse(**response.json())assert response.status_code == 201assert new_user.email == "abdullah@gmail.com"def test_login_user(client):response = client.post("/login", data={"username": "abdullah@gmail.com", "password": "abdullah1234"})assert response.status_code==200
tests/database.py+2-2
tests/test_users.py+5-1