Skip to content

Commit

Permalink
deleted temp test codes added on the last commit
Browse files Browse the repository at this point in the history
  • Loading branch information
taka-rl committed Oct 15, 2024
1 parent 6266195 commit 126aeed
Showing 1 changed file with 0 additions and 85 deletions.
85 changes: 0 additions & 85 deletions tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,88 +63,3 @@ def test_delete_user(super_admin_client):
# Verify the user exists in the database
user = User.query.filter_by(email=TEST_EMAIL).first()
assert user is None


# temp test codes using client
def test_admin_dashboard_access_tmp(client):
# log in as super admin user
login_response = client.post('/login', data={
'email': SUPER_ADMIN_EMAIL,
'password': SUPER_ADMIN_PASSWORD
})
assert login_response.status_code == 302 # Expecting a redirect after a successful registration

response = client.get('/admin-dashboard')
assert response.status_code == 200 # Check if registration redirects after success
assert b'Admin Dashboard' in response.data


def test_change_user_role_tmp(client):
# Create a new user manually for testing
new_user = User(name=TEST_NAME,
email=TEST_EMAIL,
password=generate_password_hash(TEST_PASSWORD)
)

with client.application.app_context():
db.session.add(new_user)
db.session.commit()

# Verify the registered user exists in the database
user = User.query.filter_by(email=TEST_EMAIL).first()
assert user is not None
assert user.role == 'user'

# log in as super admin user
login_response = client.post('/login', data={
'email': SUPER_ADMIN_EMAIL,
'password': SUPER_ADMIN_PASSWORD
})
assert login_response.status_code == 302 # Expecting a redirect after a successful registration

response = client.get('/admin-dashboard')
assert response.status_code == 200 # Check if registration redirects after success
assert b'Admin Dashboard' in response.data

# Super admin changes the role of the new user
response = client.post(f'/admin/change-role/{user.id}')
assert response.status_code == 302

# Verify the role has been changed
user = db.session.get(User, user.id)
assert user.role == 'admin'


def test_delete_user_tmp(client):
# Create a new user manually for testing
new_user = User(name='Test User',
email=TEST_EMAIL,
password=generate_password_hash(TEST_PASSWORD)
)

with client.application.app_context():
db.session.add(new_user)
db.session.commit()

# Verify the user exists in the database
user = User.query.filter_by(email=TEST_EMAIL).first()
assert user is not None

# log in as super admin user
login_response = client.post('/login', data={
'email': SUPER_ADMIN_EMAIL,
'password': SUPER_ADMIN_PASSWORD
})
assert login_response.status_code == 302 # Expecting a redirect after a successful registration

response = client.get('/admin-dashboard')
assert response.status_code == 200 # Check if registration redirects after success
assert b'Admin Dashboard' in response.data

# Super admin changes the role of the new user
response = client.post(f'/admin/delete-user/{user.id}')
assert response.status_code == 302

# Verify the user exists in the database
user = User.query.filter_by(email=TEST_EMAIL).first()
assert user is None

0 comments on commit 126aeed

Please sign in to comment.