Skip to content

Commit

Permalink
Merge pull request #84 from ADORSYS-GIS/feature-56-testing-user-input…
Browse files Browse the repository at this point in the history
…-functionality

Feature 56 testing user input functionality
  • Loading branch information
Bansikah authored Nov 24, 2023
2 parents 2a0da92 + c13d2c0 commit 6814d4c
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ __pycache__
*.pyc
.DS_Store
project
node_modules
node_modules
5 changes: 1 addition & 4 deletions templates/input.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,8 @@ <h2>Input Webpage URLs</h2>

{% block title %}
Input webpages URLs
<<<<<<< HEAD
{% endblock %}
=======
{% endblock %}
<!-- Link to the external CSS file -->
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">

>>>>>>> 125f26f853efebe632ddb5a214d0d9aad58931fa

33 changes: 33 additions & 0 deletions test/user_functionality.py
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()

0 comments on commit 6814d4c

Please sign in to comment.