diff --git a/.travis.yml b/.travis.yml index 64be50c..f0a3eb3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,5 +4,6 @@ python: # command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors install: - pip install requests + - pip install nose # command to run tests, e.g. python setup.py test -script: python hackertray/hn_test.py \ No newline at end of file +script: nosetests \ No newline at end of file diff --git a/hackertray/__init__.py b/hackertray/__init__.py index e29496a..6bbce21 100644 --- a/hackertray/__init__.py +++ b/hackertray/__init__.py @@ -27,7 +27,7 @@ except ImportError: __version = "Can't read version number." from hackernews import HackerNews - +from chrome import Chrome class HackerNewsApp: HN_URL_PREFIX = "https://news.ycombinator.com/item?id=" diff --git a/hackertray/chrome.py b/hackertray/chrome.py new file mode 100644 index 0000000..b85173c --- /dev/null +++ b/hackertray/chrome.py @@ -0,0 +1,20 @@ +import sqlite3 +import shutil + +class Chrome: + @staticmethod + def search(urls, config_folder_path): + HackerNews.setup() + conn = sqlite3.connect('/tmp/chrome') + db = conn.cursor() + result = [] + for url in urls: + db_result = db.execute('SELECT url from urls WHERE url=:url',{"url":url}) + if(db.fetchone() == None): + result.append(False) + else: + result.append(True) + return result + @staticmethod + def setup(): + shutil.copyfile(config_folder_path+'/History', '/tmp/hackertray.chrome') \ No newline at end of file diff --git a/test/History b/test/History new file mode 100644 index 0000000..e4016ac Binary files /dev/null and b/test/History differ diff --git a/test/chrome_test.py b/test/chrome_test.py new file mode 100644 index 0000000..41309b7 --- /dev/null +++ b/test/chrome_test.py @@ -0,0 +1,17 @@ +import unittest +import os + +from hackertray import Chrome + +class ChromeTest(unittest.TestCase): + def runTest(self): + self.assertTrue(True) + ''' + config_folder_path = os.getcwd()+'/tests/' + data = GoogleChrome.search([ + "https://github.com/", + "https://news.ycombinator.com/", + "https://github.com/captn3m0/hackertray", + "http://invalid_url/"], + config_folder_path) + self.assertTrue(data == [True,True,True,False])''' \ No newline at end of file diff --git a/hackertray/hn_test.py b/test/hn_test.py similarity index 77% rename from hackertray/hn_test.py rename to test/hn_test.py index 182631a..07bec2d 100644 --- a/hackertray/hn_test.py +++ b/test/hn_test.py @@ -1,6 +1,5 @@ import unittest -from hackernews import HackerNews - +from hackertray import HackerNews class HNTest(unittest.TestCase): def runTest(self):