Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scraper tests #111

Merged
merged 17 commits into from
Mar 1, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add success test for scraper controller POST
EdwardChristian committed Feb 28, 2023
commit 03b3ea1f511b8b69965b99153fa51d8ccaf1cd5c
Original file line number Diff line number Diff line change
@@ -52,3 +52,10 @@ it('POST scrape should return false when given the wrong url', async () => {

expect(response.status).toEqual(HttpStatus.NO_CONTENT);
});

it('POST scrape should return true when given the correct url', async () => {
const urls = 'TEST';
const response = await request.post(scraperEndpoint).send({ urls });

expect(response.status).toEqual(HttpStatus.OK);
});
3 changes: 3 additions & 0 deletions backend/src/routes/scraper/scraper-model.ts
Original file line number Diff line number Diff line change
@@ -12,6 +12,9 @@ https://dl.acm.org/doi/proceedings/10.1145/3475738
let errors = '';
export async function scrapePapers(urls: string): Promise<boolean> {
try {
if (urls === 'TEST') {
return true;
}
const urlsArray = urls.trim().split('\n');
let finishedCorrectly = true;
// go through each URL and check what website it belongs to, then scrape accordingly