Exemplo n.º 1
0
class TestSqlLiteWraper(unittest.TestCase):
    def setUp(self):
        self.sql_wraper = SqlLiteWraper(r"tests\test_web_crawler.db3")

    def test_init_(self):
        self.sql_wraper.db_src = r"tests\web_crawler.db3"

    def test_read_db(self):
        custom_query = self.sql_wraper._from_db(query="SELECT id FROM songs_data")
        exp_custom_query = {1, 2, 3}
        self.assertEqual(custom_query, exp_custom_query)

        two_cols_query = self.sql_wraper._from_db(query="SELECT artist, new_song_flag FROM songs_data")
        exp_two_col_query = [('Darude', 0), ('Enia', 0), ('Michael Jackson', 1)]
        self.assertEqual(two_cols_query, exp_two_col_query)

    def test_get_urls_list(self):
        pend_urls = self.sql_wraper.get_urls_list(url_type="pending")
        exp_pend_urls = {"http://songs.arch/2", "http://songs.arch/3"}
        self.assertEqual(pend_urls, exp_pend_urls)

    def test_append_new_urls(self):
        # kasowanie jezeli cos jest
        self.sql_wraper._execute_stmt(query="DELETE FROM url_history_empty")

        new_urls = {"http://songs.arch/12", "http://songs.arch/13"}
        self.sql_wraper.append_new_urls(new_urls)

        sql_new_urls = self.sql_wraper._from_db("SELECT url FROM url_history_empty")
        self.assertEqual(new_urls, sql_new_urls)
Exemplo n.º 2
0
class TestSqlLiteWraper(unittest.TestCase):
    def setUp(self):
        self.sql_wraper = SqlLiteWraper(r"tests\test_web_crawler.db3")

    def test_init_(self):
        self.sql_wraper.db_src = r"tests\web_crawler.db3"

    def test_read_db(self):
        custom_query = self.sql_wraper._from_db(
            query="SELECT id FROM songs_data")
        exp_custom_query = {1, 2, 3}
        self.assertEqual(custom_query, exp_custom_query)

        two_cols_query = self.sql_wraper._from_db(
            query="SELECT artist, new_song_flag FROM songs_data")
        exp_two_col_query = [('Darude', 0), ('Enia', 0),
                             ('Michael Jackson', 1)]
        self.assertEqual(two_cols_query, exp_two_col_query)

    def test_get_urls_list(self):
        pend_urls = self.sql_wraper.get_urls_list(url_type="pending")
        exp_pend_urls = {"http://songs.arch/2", "http://songs.arch/3"}
        self.assertEqual(pend_urls, exp_pend_urls)

    def test_append_new_urls(self):
        # kasowanie jezeli cos jest
        self.sql_wraper._execute_stmt(query="DELETE FROM url_history_empty")

        new_urls = {"http://songs.arch/12", "http://songs.arch/13"}
        self.sql_wraper.append_new_urls(new_urls)

        sql_new_urls = self.sql_wraper._from_db(
            "SELECT url FROM url_history_empty")
        self.assertEqual(new_urls, sql_new_urls)
Exemplo n.º 3
0
 def setUp(self):
     self.sql_wraper = SqlLiteWraper(r"tests\test_web_crawler.db3")
Exemplo n.º 4
0
 def setUp(self):
     self.sql_wraper = SqlLiteWraper(r"tests\test_web_crawler.db3")