Commit 3bdd6331 authored by D.H.D. Nguyen's avatar D.H.D. Nguyen
Browse files

update tests

parent c565f560
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@ def test_valid_annotator(test_client, init_database):
	GIVEN a Flask application
	WHEN an annotator uses a keyword on the '/user/signup' page (POST) 
	which is never used from other annotators
	THEN check if:
	THEN check if it is redirected to the right route:
		1. the response is valid 
		-> annotator is redirected to the project homepage '/annotator/test' (GET)
		2. it renders the right template 
@@ -31,7 +31,7 @@ def test_valid_annotator(test_client, init_database):
	GIVEN a Flask application
	WHEN an annotator uses a keyword on the '/user/signup' page (POST) 
	that he has already used and can type in his pseudoname (self defined) again
	THEN check if:
	THEN check if is redirected to the right route:
		1. the response is valid 
		-> annotator is redirected to the project homepage '/annotator/test' (GET)
		2. it renders the right template 
@@ -53,7 +53,7 @@ def test_invalid_keyword(test_client, init_database):
	"""
	GIVEN a Flask application
	WHEN an annotator types in a wrong keyword on the '/annotator' page (POST)
	THEN check if:
	THEN check if it is not redirected to any other routes due to invalid inputs:
		1. the response is valid -> annotator stays at main page at '/annotator' (GET)
		2. it renders the right template 
		(template 'templates/annotator/index.html' has page title of 'Annotator - Main page'
@@ -74,7 +74,7 @@ def test_invalid_name(test_client, init_database):
	GIVEN a Flask application
	WHEN an annotator types in the right keyword but specifies the wrong name on the '/user/signup' page (POST)
	as this keyword is used from an another user
	THEN check if:
	THEN check if it is not redirected to any other routes due to invalid inputs:
		1. the response is valid (annotator stays on the main page) -> GET
		2. it renders the right template 
		(template 'templates/annotator/index.html' has page title of 'Annotator - Main page'
+6 −6
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@ def test_batch(test_client, init_database):
	GIVEN a Flask application
	WHEN a logged-in annotator wants to start the annotation on a batch, 
	e.g. '/annotator/test/batch-1' page is requested (GET)
	THEN check if:
	THEN check if it is redirected to the right route:
		1. the response is valid -> it is redirected to the page of batch 1
		2. it renders the right template 
		   (template 'templates/annotator/batch.html' has page title 'BATCH 1')
@@ -36,7 +36,7 @@ def test_submit_invalid_batch(test_client, init_database):
	"""
	GIVEN a Flask application
	WHEN a logged in annotator submits an annotation of a tuple with the same answer for 'best' and 'worst' at e.g. '/annotator/test/batch-1' page (POST)
	THEN check if:
	THEN check if it is not redirected to any other routes due to invalid inputs:
		1. the response is valid (annotator is redirected to the project page) -> GET
		2. it renders the right template 
		(template 'templates/annotator/project.html' has page title of project name 'TEST'
@@ -81,7 +81,7 @@ def test_submit_valid_batch(test_client, init_database):
	"""
	GIVEN a Flask application
	WHEN a logged in annotator submits a valid annotation on the e.g. '/annotator/test/batch-1' page (POST)
	THEN check if:
	THEN check if is redirected to the right route:
		1. the response is valid (annotator is redirected to the project page) -> GET
		2. it renders the right template 
		(template 'templates/annotator/project.html' has page title of project name 'TEST'
@@ -102,12 +102,12 @@ def test_submit_valid_batch(test_client, init_database):
	assert b"Admin" in response.data
	assert b"Batch 1 successfully submitted!" in response.data

def test_reupload_same_valid_batch(test_client, init_database):
def test_resubmit_same_batch(test_client, init_database):
	"""
	GIVEN a Flask application
	WHEN a logged in annotator submits a valid annotation again for a submitted batch 
	WHEN a logged in annotator submits an annotation again for a submitted batch (no matter if it is valid or not)
		at e.g. '/annotator/test/batch-1' page (POST)
	THEN check if:
	THEN check if it is redirected to the right route:
		1. the response is valid (annotator is redirected to the project page) -> GET
		2. it renders the right template 
		(template 'templates/annotator/project.html' has page title of project name 'TEST'
+5 −5
Original line number Diff line number Diff line
@@ -6,9 +6,9 @@ def test_home_page(test_client):
	"""
	GIVEN a Flask application
	WHEN the '/' page is requested (GET)
	THEN 
		1. check the response is valid
		2. check if it renders the right template 
	THEN check if is redirected to the right route:
		1. if the response is valid
		2. if it renders the right template 
		   (template **templates/start.html** has page title 'Homepage')
	"""
	response = test_client.get('/')
@@ -20,7 +20,7 @@ def test_user_homepage(test_client):
	"""
	GIVEN a Flask application
	WHEN the '/user' page is requested (GET)
	THEN check if:
	THEN check if it is redirected to the right route:
		1. the response is valid
		2. it renders the right template 
		   (template 'templates/user/index.html' has page title 'User - Homepage')
@@ -39,7 +39,7 @@ def test_annotator_homepage(test_client):
	"""
	GIVEN a Flask application
	WHEN the '/annotator' page is requested (GET)
	THEN check if:
	THEN check if it is redirected to the right route:
		1. the response is valid
		2. it renders the right template 
		   (template 'templates/annotator/index.html' has page title 'Annotator - Main page')
+8 −8
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@ def test_upload_project(test_client, init_database):
	"""
	GIVEN a Flask application
	WHEN the '/user/upload-project' page is requested (GET) from a logged-in user
	THEN check if:
	THEN check if it is redirected to the right route:
		1. the response is valid
		2. it renders the right template 
		   (template 'templates/user/upload-project.html' has page title 'UPLOAD PROJECT')
@@ -36,7 +36,7 @@ def test_upload_file_no_required_extensions(test_client, init_database):
	"""
	GIVEN a Flask application
	WHEN an logged-in user uploads only files on '/user/upload-project' that don't have the required extensions (POST)
	THEN check if:
	THEN check if it is not redirected to any other routes due to invalid inputs:
		1. the response is valid  -> user stays at '/user/upload-project' (GET)
		2. it renders the right template 
		(template 'templates/user/upload-project.html' has page title 'UPLOAD PROJECT')
@@ -61,7 +61,7 @@ def test_upload_empty_files(test_client, init_database):
	"""
	GIVEN a Flask application
	WHEN an logged-in user uploads only empty valid txt-files on '/user/upload-project' (POST)
	THEN check if:
	THEN check if it is not redirected to any other routes due to invalid inputs:
		1. the response is valid  -> user stays at '/user/upload-project' (GET)
		2. it renders the right template 
		(template 'templates/user/upload-project.html' has page title 'UPLOAD PROJECT')
@@ -86,7 +86,7 @@ def test_upload_few_items(test_client, init_database):
	"""
	GIVEN a Flask application
	WHEN an logged-in user uploads valid txt-files on '/user/upload-project' but all of items are fewer than 5 (POST)
	THEN check if:
	THEN check if it is not redirected to any other routes due to invalid inputs:
		1. the response is valid  -> user stays at '/user/upload-project' (GET)
		2. it renders the right template 
		(template 'templates/user/upload-project.html' has page title 'UPLOAD PROJECT')
@@ -112,7 +112,7 @@ def test_upload_same_best_worst_def(test_client, init_database):
	GIVEN a Flask application
	WHEN an logged-in user fills every required field on '/user/upload-project' 
		but set the definition for best and worst are the same (POST)
	THEN check if:
	THEN check if it is not redirected to any other routes due to invalid inputs:
		1. the response is valid  -> user stays at '/user/upload-project' (GET)
		2. it renders the right template 
		(template 'templates/user/upload-project.html' has page title 'UPLOAD PROJECT')
@@ -138,7 +138,7 @@ def test_upload_short_description(test_client, init_database):
	GIVEN a Flask application
	WHEN an logged-in user uploads a project on '/user/upload-project' 
		with a very short project description (fewer than 10 characters) (POST)
	THEN check if:
	THEN check if it is not redirected to any other routes due to invalid inputs:
		1. the response is valid -> user stays at '/user/upload-project' (GET)
		2. it renders the right template 
		(template 'templates/user/upload-project.html' has page title 'UPLOAD PROJECT')
@@ -164,7 +164,7 @@ def test_upload_no_anno_number(test_client, init_database):
	GIVEN a Flask application
	WHEN an logged-in user uploads a project on '/user/upload-project' 
		without providing number of expected annotators for the project (POST)
	THEN check if:
	THEN check if it is not redirected to any other routes due to invalid inputs:
		1. the response is valid -> user stays at '/user/upload-project' (GET)
		2. it renders the right template 
		(template 'templates/user/upload-project.html' has page title 'UPLOAD PROJECT')
@@ -186,7 +186,7 @@ def test_upload_valid_project(test_client, init_database):
	"""
	GIVEN a Flask application
	WHEN an logged-in user uploads a valid project on '/user/upload-project' (POST)
	THEN check if:
	THEN check if it is redirected to the right route:
		1. the response is valid (user is redirected to the valid username page) -> GET
		2. it renders the right template 
		(template 'templates/user/profile.html' has page title of 'JUNG' as logged in username is 'jung')
+10 −10
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@ def test_user_signup(test_client):
	"""
	GIVEN a Flask application
	WHEN the '/user/signup' page is requested (GET)
	THEN check if:
	THEN check if it is redirected to the right route:
		1. the response is valid
		2. it renders the right template 
		   (template 'templates/user/signup.html' has page title 'SIGNUP')
@@ -30,7 +30,7 @@ def test_valid_signup(test_client, init_database):
	"""
	GIVEN a Flask application
	WHEN a new user signs up on the '/user/signup' page (POST) with a valid username and email
	THEN check if:
	THEN check if it is redirected to the right route:
		1. the response is valid (user is redirected to the user homepage) -> GET
		2. it renders the right template 
		(template 'templates/user/index.html' has page title of 'User - Homepage'
@@ -51,7 +51,7 @@ def test_invalid_username_signup(test_client, init_database):
	"""
	GIVEN a Flask application
	WHEN a user wants to sign up on the '/user/signup' page (POST) with an existing username
	THEN check if:
	THEN check if it is not redirected to any other routes due to invalid inputs:
		1. the response is valid (GET) -> it stays at '/user/signup'
		2. it renders the right template 
		   (template 'templates/user/signup.html' has page title 'SIGNUP')
@@ -109,7 +109,7 @@ def test_invalid_email_signup(test_client, init_database):
	"""
	GIVEN a Flask application
	WHEN a user wants to sign up on the '/user/signup' page (POST) with an existing email
	THEN check if:
	THEN check if it is not redirected to any other routes due to invalid inputs:
		1. the response is valid (GET) -> it stays at '/user/signup'
		2. it renders the right template 
		   (template 'templates/user/signup.html' has page title 'SIGNUP')
@@ -148,7 +148,7 @@ def test_invalid_password_signup(test_client, init_database):
	"""
	GIVEN a Flask application
	WHEN a user wants to sign up on the '/user/signup' page (POST) with a password that does not meet the length requirement
	THEN check if:
	THEN check if it is not redirected to any other routes due to invalid inputs:
		1. the response is valid (GET) -> it stays at '/user/signup'
		2. it renders the right template 
		   (template 'templates/user/signup.html' has page title 'SIGNUP')
@@ -168,7 +168,7 @@ def test_user_login(test_client):
	"""
	GIVEN a Flask application
	WHEN the '/user/login' page is requested (GET)
	THEN check if:
	THEN check if it is redirected to the right route:
		1. the response is valid
		2. it renders the right template 
		   (template 'templates/user/login.html' has page title 'LOGIN')
@@ -191,7 +191,7 @@ def test_valid_login_logout(test_client, init_database):
	"""
	GIVEN a Flask application
	WHEN a user logs in on the '/user/login' page (POST) with a valid username
	THEN check if:
	THEN check if it is redirected to the right route:
		1. the response is valid (user is redirected to the valid username page) -> GET
		2. it renders the right template 
		(template 'templates/user/profile.html' has page title of 'JUNG' as logged in username is 'jung')
@@ -207,7 +207,7 @@ def test_valid_login_logout(test_client, init_database):
	"""
	GIVEN a Flask application
	WHEN a logged in user logs out (the '/user/logout' page is requested) (GET)
	THEN check if:
	THEN check if it is redirected to the right route:
		1. the response is valid (user is redirected to the 'User - Homepage') -> GET
		2. it renders the right template 
		   (template 'templates/user/index.html' has page title 'User - Homepage')
@@ -228,7 +228,7 @@ def test_invalid_username_login(test_client, init_database):
	"""
	GIVEN a Flask application
	WHEN a user logs in on the '/user/login' page (POST) with a username that is not registered
	THEN check if:
	THEN check if it is not redirected to any other routes due to invalid inputs:
		1. the response is valid (GET) -> it stays at '/user/login'
		2. it renders the right template 
		   (template 'templates/user/login.html' has page title 'LOGIN')
@@ -248,7 +248,7 @@ def test_invalid_password_login(test_client, init_database):
	"""
	GIVEN a Flask application
	WHEN a user logs in on the '/user/login' page (POST) with an existing username but with wrong password
	THEN check if:
	THEN check if it is not redirected to any other routes due to invalid inputs:
		1. the response is valid (GET) -> it stays at '/user/login'
		2. it renders the right template 
		   (template 'templates/user/login.html' has page title 'LOGIN')
Loading