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
handle-network-errors
Abhay Rana 9 years ago
parent 992961071c
commit 0586db9d72
  1. 3
      .travis.yml
  2. 2
      hackertray/__init__.py
  3. 20
      hackertray/chrome.py
  4. BIN
      test/History
  5. 17
      test/chrome_test.py
  6. 3
      test/hn_test.py

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

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

@ -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
from hackernews import HackerNews
from hackertray import HackerNews
class HNTest(unittest.TestCase):
def runTest(self):
Loading…
Cancel
Save