Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Crisis Events Text Summarization
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
Container 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
Francesco Crisafulli
Crisis Events Text Summarization
Commits
4eff1a31
Commit
4eff1a31
authored
11 months ago
by
Farhan Mohammed
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
6009f5ec
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test-scraper.py
+27
-0
27 additions, 0 deletions
test-scraper.py
with
27 additions
and
0 deletions
test-scraper.py
0 → 100644
+
27
−
0
View file @
4eff1a31
import
unittest
from
scraper
import
scrape_webpage
class
TestWebScraping
(
unittest
.
TestCase
):
def
test_scrape_valid_page
(
self
):
"""
Test scraping a valid webpage to ensure it retrieves text.
"""
# This link should be replaced with a known, stable webpage for testing
test_link
=
"
http://example.com
"
result
=
scrape_webpage
(
test_link
)
self
.
assertIn
(
"
link
"
,
result
)
self
.
assertIn
(
"
text
"
,
result
)
self
.
assertNotEqual
(
result
[
"
text
"
],
""
,
"
The scraped text should not be empty.
"
)
def
test_scrape_invalid_page
(
self
):
"""
Test scraping an invalid webpage to check error handling.
"""
# This should be a link that will likely return a 404 or other client/server error
test_link
=
"
http://example.com/nonexistentpage
"
result
=
scrape_webpage
(
test_link
)
self
.
assertTrue
(
"
Error identified
"
in
result
)
if
__name__
==
'
__main__
'
:
unittest
.
main
()
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