mirror of
https://github.com/captn3m0/hackertray.git
synced 2024-09-08 07:46:43 +00:00
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
|
||||
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="
|
||||
|
20
hackertray/chrome.py
Normal file
20
hackertray/chrome.py
Normal 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
BIN
test/History
Normal file
Binary file not shown.
17
test/chrome_test.py
Normal file
17
test/chrome_test.py
Normal 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])'''
|
@ -1,6 +1,5 @@
|
||||
import unittest
|
||||
from hackernews import HackerNews
|
||||
|
||||
from hackertray import HackerNews
|
||||
|
||||
class HNTest(unittest.TestCase):
|
||||
def runTest(self):
|
Loading…
Reference in New Issue
Block a user