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:
Abhay Rana 2014-06-07 02:42:59 +05:30
parent 992961071c
commit 0586db9d72
6 changed files with 41 additions and 4 deletions

View File

@ -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
script: nosetests

View File

@ -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="

20
hackertray/chrome.py Normal file
View File

@ -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')

BIN
test/History Normal file

Binary file not shown.

17
test/chrome_test.py Normal file
View File

@ -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])'''

View File

@ -1,6 +1,5 @@
import unittest
from hackernews import HackerNews
from hackertray import HackerNews
class HNTest(unittest.TestCase):
def runTest(self):