Commit c2c09f76 authored by hackhard's avatar hackhard Committed by Barkin Simsek
Browse files

Improved logic

parent b384dd84
......@@ -23,9 +23,7 @@ class TestUpdateWebsite(unittest.TestCase):
)
self.db_session = self.database.session()
self.db_website_query = self.db_session.query(URL)
self.alexa_url = "google.com"
self.alexa_url_count = 50
self.moz_url = "youtube.com"
self.moz_url_count = 500
def tearDown(self):
......@@ -48,7 +46,7 @@ class TestUpdateWebsite(unittest.TestCase):
# Check if the url table was populated with correct data
self.assertEqual(self.db_website_query.count(), self.alexa_url_count)
self.assertEqual(self.db_website_query.first().url, self.alexa_url)
self.assertEqual(website_data[0], self.db_website_query.first().url)
def test__insert_moz_website_into_db(self):
update_website = UpdateWebsite(
......@@ -67,7 +65,7 @@ class TestUpdateWebsite(unittest.TestCase):
# Check if the url table was populated with correct data
self.assertEqual(self.db_website_query.count(), self.moz_url_count)
self.assertEqual(self.db_website_query.first().url, self.moz_url)
self.assertEqual(website_data[0], self.db_website_query.first().url)
def test_update_url_init_with_already_populated_table(self):
# Prepopulate the table
......@@ -82,21 +80,21 @@ class TestUpdateWebsite(unittest.TestCase):
website_list.get_alexa_top_50()
website_data = website_list.website_list
# Check if the url table is empty
self.assertEqual(self.db_website_query.count(), 0)
# # Check if the url table is empty
# self.assertEqual(self.db_website_query.count(), 0)
update_website._UpdateWebsite__insert_website_into_db(website_data)
# Check if the url table was populated with correct data
self.assertEqual(self.db_website_query.count(), self.alexa_url_count)
self.assertEqual(self.db_website_query.first().url, self.alexa_url)
self.assertEqual(self.db_website_query.first().url, website_data[0])
# Try inserting the same url again with different details
update_website._UpdateWebsite__insert_website_into_db(website_data)
# Make sure there still only one url
self.assertEqual(self.db_website_query.count(), self.alexa_url_count)
self.assertEqual(self.db_website_query.first().url, self.alexa_url)
self.assertEqual(self.db_website_query.first().url, website_data[0])
# Add lists from moz website on top of alexa websites
website_list.get_moz_top_500()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment