Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
rxd
AI
Commits
30aa5fa6
Commit
30aa5fa6
authored
2 years ago
by
rxd
Browse files
Options
Downloads
Patches
Plain Diff
comments added to tests.
parent
76798f53
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
tests/test_generate.py
+3
-0
3 additions, 0 deletions
tests/test_generate.py
tests/test_index.py
+1
-7
1 addition, 7 deletions
tests/test_index.py
tests/test_search.py
+3
-9
3 additions, 9 deletions
tests/test_search.py
tests/test_setup.py
+1
-0
1 addition, 0 deletions
tests/test_setup.py
with
8 additions
and
16 deletions
tests/test_generate.py
+
3
−
0
View file @
30aa5fa6
...
@@ -9,6 +9,7 @@ import re
...
@@ -9,6 +9,7 @@ import re
import
bs4
import
bs4
def
test_generate_empty
(
client
):
def
test_generate_empty
(
client
):
"""
Test if only no field is valid.
"""
url
=
'
/generate?top=&url=https%3A%2F%2Flive.staticflickr.com%2F3606%2F3369014165_7441c25d45_q.jpg&bot=
'
url
=
'
/generate?top=&url=https%3A%2F%2Flive.staticflickr.com%2F3606%2F3369014165_7441c25d45_q.jpg&bot=
'
response
=
client
.
get
(
url
)
response
=
client
.
get
(
url
)
soup
=
bs4
.
BeautifulSoup
(
response
.
data
,
"
html.parser
"
)
soup
=
bs4
.
BeautifulSoup
(
response
.
data
,
"
html.parser
"
)
...
@@ -23,6 +24,7 @@ def test_generate_empty(client):
...
@@ -23,6 +24,7 @@ def test_generate_empty(client):
assert
re
.
match
(
first_part_reg
,
first_part
)
is
not
None
assert
re
.
match
(
first_part_reg
,
first_part
)
is
not
None
def
test_generate_one_empty
(
client
):
def
test_generate_one_empty
(
client
):
"""
Test if only one field is valid.
"""
bot_url
=
'
/generate?top=&url=https%3A%2F%2Flive.staticflickr.com%2F3606%2F3369014165_7441c25d45_q.jpg&bot=bot
'
bot_url
=
'
/generate?top=&url=https%3A%2F%2Flive.staticflickr.com%2F3606%2F3369014165_7441c25d45_q.jpg&bot=bot
'
top_url
=
'
/generate?top=top&url=https%3A%2F%2Flive.staticflickr.com%2F3606%2F3369014165_7441c25d45_q.jpg&bot=
'
top_url
=
'
/generate?top=top&url=https%3A%2F%2Flive.staticflickr.com%2F3606%2F3369014165_7441c25d45_q.jpg&bot=
'
# bot first
# bot first
...
@@ -46,6 +48,7 @@ def test_generate_one_empty(client):
...
@@ -46,6 +48,7 @@ def test_generate_one_empty(client):
assert
re
.
match
(
first_part_reg
,
first_part
)
is
not
None
assert
re
.
match
(
first_part_reg
,
first_part
)
is
not
None
def
check_generate_full
(
client
):
def
check_generate_full
(
client
):
"""
Test if fully filled is valid.
"""
url
=
'
/generate?top=a&url=https%3A%2F%2Flive.staticflickr.com%2F3606%2F3369014165_7441c25d45_q.jpg&bot=c
'
url
=
'
/generate?top=a&url=https%3A%2F%2Flive.staticflickr.com%2F3606%2F3369014165_7441c25d45_q.jpg&bot=c
'
response
=
client
.
get
(
url
)
response
=
client
.
get
(
url
)
soup
=
bs4
.
BeautifulSoup
(
response
.
data
,
"
html.parser
"
)
soup
=
bs4
.
BeautifulSoup
(
response
.
data
,
"
html.parser
"
)
...
...
This diff is collapsed.
Click to expand it.
tests/test_index.py
+
1
−
7
View file @
30aa5fa6
...
@@ -5,17 +5,11 @@ MemeGenerator
...
@@ -5,17 +5,11 @@ MemeGenerator
Ruizhe Deng rxd@umich.edu
Ruizhe Deng rxd@umich.edu
"""
"""
import
re
import
bs4
import
bs4
def
test_images
(
client
):
def
test_images
(
client
):
"""
Verify all images are present in / URL.
"""
Test the layout and link in the index page.
"""
Note:
'
client
'
is a fixture fuction that provides a Flask test server
interface with a clean database. It is implemented in conftest.py and
reused by many tests. Docs: https://docs.pytest.org/en/latest/fixture.html
"""
# Load and parse index page
# Load and parse index page
response
=
client
.
get
(
"
/
"
)
response
=
client
.
get
(
"
/
"
)
assert
response
.
status_code
==
200
assert
response
.
status_code
==
200
...
...
This diff is collapsed.
Click to expand it.
tests/test_search.py
+
3
−
9
View file @
30aa5fa6
...
@@ -5,17 +5,10 @@ MemeGenerator
...
@@ -5,17 +5,10 @@ MemeGenerator
Ruizhe Deng rxd@umich.edu
Ruizhe Deng rxd@umich.edu
"""
"""
import
re
import
bs4
import
bs4
def
test_search
(
client
):
def
test_check_content
(
client
):
"""
Verify expected links present in / URL.
"""
Check the search page
'
s content
"""
Note:
'
client
'
is a fixture fuction that provides a Flask test server
interface with a clean database. It is implemented in conftest.py and
reused by many tests. Docs: https://docs.pytest.org/en/latest/fixture.html
"""
response
=
client
.
get
(
"
/search/1?q=umich
"
)
response
=
client
.
get
(
"
/search/1?q=umich
"
)
assert
response
.
status_code
==
200
assert
response
.
status_code
==
200
soup
=
bs4
.
BeautifulSoup
(
response
.
data
,
"
html.parser
"
)
soup
=
bs4
.
BeautifulSoup
(
response
.
data
,
"
html.parser
"
)
...
@@ -30,6 +23,7 @@ def test_search(client):
...
@@ -30,6 +23,7 @@ def test_search(client):
assert
'
prev
'
in
btns
assert
'
prev
'
in
btns
def
test_next_and_prev_page
(
client
):
def
test_next_and_prev_page
(
client
):
"""
Test if next and prev button works
"""
response
=
client
.
get
(
"
/search/1?q=umich
"
)
response
=
client
.
get
(
"
/search/1?q=umich
"
)
assert
response
.
status_code
==
200
or
response
.
status_code
==
304
assert
response
.
status_code
==
200
or
response
.
status_code
==
304
soup
=
bs4
.
BeautifulSoup
(
response
.
data
,
"
html.parser
"
)
soup
=
bs4
.
BeautifulSoup
(
response
.
data
,
"
html.parser
"
)
...
...
This diff is collapsed.
Click to expand it.
tests/test_setup.py
+
1
−
0
View file @
30aa5fa6
...
@@ -9,6 +9,7 @@ import re
...
@@ -9,6 +9,7 @@ import re
import
bs4
import
bs4
def
test_layout
(
client
):
def
test_layout
(
client
):
"""
Test for layout and link.
"""
response
=
client
.
get
(
"
http://localhost:8000/setup?url=https%3A%2F%2Flive.staticflickr.com%2F3606%2F3369014165_7441c25d45_q.jpg
"
)
response
=
client
.
get
(
"
http://localhost:8000/setup?url=https%3A%2F%2Flive.staticflickr.com%2F3606%2F3369014165_7441c25d45_q.jpg
"
)
assert
response
.
status_code
==
200
assert
response
.
status_code
==
200
soup
=
bs4
.
BeautifulSoup
(
response
.
data
,
"
html.parser
"
)
soup
=
bs4
.
BeautifulSoup
(
response
.
data
,
"
html.parser
"
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment