Пример #1
0
    def test_top_stories_func(self):
        finproj.initialize_db()
        finproj.fill_db()
        conn = finproj.sqlite3.connect(finproj.DBNAME)
        cur = conn.cursor()
        data = finproj.top_stories_func()

        self.assertEqual(len(data), 84)

        conn.commit()
        conn.close()
Пример #2
0
    def test_phrases_func(self):
        finproj.initialize_db()
        finproj.fill_db()
        conn = finproj.sqlite3.connect(finproj.DBNAME)
        cur = conn.cursor()
        data = finproj.phrases_func()

        self.assertGreater(len(data), 150)

        conn.commit()
        conn.close()
Пример #3
0
    def test_phrases_results_func(self):
        finproj.initialize_db()
        finproj.fill_db()
        conn = finproj.sqlite3.connect(finproj.DBNAME)
        cur = conn.cursor()

        data = finproj.phrases_results_func("design")
        self.assertGreater(len(data), 10)

        data2 = finproj.phrases_results_func("folleyes")
        self.assertLessEqual(len(data2), 1)

        conn.commit()
        conn.close()
Пример #4
0
    def test_database(self):
        finproj.initialize_db()
        finproj.fill_db()
        conn = finproj.sqlite3.connect(finproj.DBNAME)
        cur = conn.cursor()

        statement1 = []
        for item in cur.execute('''SELECT Title FROM Articles'''):
            statement1.append(item)

        statement2 = []
        for item in cur.execute('''SELECT Phrase FROM Phrases'''):
            statement2.append(item)

        self.assertEqual(len(statement1), 84)
        self.assertGreater(len(str(statement1[0])), 5)
        self.assertGreater(len(statement2), 150)
        self.assertGreater(len(str(statement2[0])), 5)

        conn.commit()
        conn.close()