-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #84 from ADORSYS-GIS/feature-56-testing-user-input…
…-functionality Feature 56 testing user input functionality
- Loading branch information
Showing
3 changed files
with
35 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,4 @@ __pycache__ | |
*.pyc | ||
.DS_Store | ||
project | ||
node_modules | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import unittest | ||
from selenium import webdriver | ||
from selenium.webdriver.common.keys import Keys | ||
from flask import Flask, request, jsonify | ||
|
||
class FlaskURLTestCase(unittest.TestCase): | ||
def setUp(self): | ||
self.app = Flask(__name__) | ||
self.app.config['TESTING'] = True | ||
self.driver = webdriver.Chrome() | ||
|
||
@self.app.route('/save_url', methods=['POST']) | ||
def scrape(): | ||
urls = request.form.getlist('urls') | ||
validated_urls = validate_urls(urls) | ||
if validated_urls: | ||
return jsonify({'message': 'Scraping in progress...', 'validated_urls': validated_urls}), 200 | ||
else: | ||
return jsonify({'error': 'Invalid URLs provided.'}), 400 | ||
|
||
def tearDown(self): | ||
self.driver.quit() | ||
|
||
def test_save_url(self): | ||
self.driver.get('http://localhost:5000') | ||
input_element = self.driver.find_element_by_name('urls') | ||
input_element.send_keys('https:/google.com') | ||
input_element.send_keys(Keys.RETURN) | ||
response = self.driver.find_element_by_tag_name('body').text | ||
self.assertIn('Scraping in progress', response) | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |