Adds chrome module for searching history.
- Restructures unit tests - Shifts to nose for unit testing - Adds a sample history file with 6 entries to search against as well
This commit is contained in:
parent
992961071c
commit
0586db9d72
|
@ -4,5 +4,6 @@ python:
|
||||||
# command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors
|
# command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors
|
||||||
install:
|
install:
|
||||||
- pip install requests
|
- pip install requests
|
||||||
|
- pip install nose
|
||||||
# command to run tests, e.g. python setup.py test
|
# command to run tests, e.g. python setup.py test
|
||||||
script: python hackertray/hn_test.py
|
script: nosetests
|
|
@ -27,7 +27,7 @@ except ImportError:
|
||||||
__version = "Can't read version number."
|
__version = "Can't read version number."
|
||||||
|
|
||||||
from hackernews import HackerNews
|
from hackernews import HackerNews
|
||||||
|
from chrome import Chrome
|
||||||
|
|
||||||
class HackerNewsApp:
|
class HackerNewsApp:
|
||||||
HN_URL_PREFIX = "https://news.ycombinator.com/item?id="
|
HN_URL_PREFIX = "https://news.ycombinator.com/item?id="
|
||||||
|
|
|
@ -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')
|
Binary file not shown.
|
@ -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])'''
|
|
@ -1,6 +1,5 @@
|
||||||
import unittest
|
import unittest
|
||||||
from hackernews import HackerNews
|
from hackertray import HackerNews
|
||||||
|
|
||||||
|
|
||||||
class HNTest(unittest.TestCase):
|
class HNTest(unittest.TestCase):
|
||||||
def runTest(self):
|
def runTest(self):
|
Loading…
Reference in New Issue