Merge pull request #24 from jonbranan/fix_dragnet_output
added dragnet test case and fixed dragnet
This commit is contained in:
commit
1653c3abce
11
qprocess.py
11
qprocess.py
@ -1,6 +1,3 @@
|
||||
from cgitb import enable
|
||||
|
||||
|
||||
def tor_processor(self):
|
||||
"""Main logic to sort through both self.tracker_nonprotected_list and self.tracker_protected_list
|
||||
If torrent meets criteria for deletion, its infohash_v1 will be appended to self.torrent_hash_delete_list
|
||||
@ -36,7 +33,7 @@ def tor_processor(self):
|
||||
self.tl.info(f'Submitted ["{canidate["name"][0:20]}..."] for deletion.')
|
||||
else:
|
||||
if self.enable_dragnet:
|
||||
dragnet(self,canidate['state'],canidate['ratio'],canidate["tags"],canidate['added_on'],self.age,self.t.time(),canidate['infohash_v1'],canidate["name"][0:20])
|
||||
dragnet(self.cv,self.dragnet_outfile,canidate['state'],canidate['ratio'],canidate["tags"],canidate['added_on'],self.age,self.t.time(),canidate['infohash_v1'],canidate["name"][0:20])
|
||||
self.tl.info(f'["{canidate["name"][0:20]}..."] is orphaned.')
|
||||
self.up_tor_counter += 1
|
||||
continue
|
||||
@ -73,11 +70,11 @@ def is_not_protected_tor(setnonprotectedtag, tortags):
|
||||
if setnonprotectedtag in tortags:
|
||||
return True
|
||||
|
||||
def dragnet(self,state,ratio,tags,added,age,time,thash,tname):
|
||||
def dragnet(csv_obj,outfile,state,ratio,tags,added,age,time,thash,tname):
|
||||
header = ['state','ratio','tags','added','age','time','thash','tname']
|
||||
row = [state,ratio,tags,added,age,time,thash,tname]
|
||||
with open(self.dragnet_outfile, 'w', encoding='UTF8', newline='') as f:
|
||||
writer = self.cv.writer(f)
|
||||
with open(outfile, 'a+', encoding='UTF8', newline='') as f:
|
||||
writer = csv_obj.writer(f)
|
||||
if f.tell() == 0:
|
||||
writer.writerow(header)
|
||||
writer.writerow(row)
|
20
test_dragnet.py
Normal file
20
test_dragnet.py
Normal file
@ -0,0 +1,20 @@
|
||||
from qprocess import dragnet
|
||||
import csv
|
||||
import unittest
|
||||
|
||||
class TestDragnet(unittest.TestCase):
|
||||
def test_dragnet_sanity(self):
|
||||
self.cv = csv
|
||||
outfile = './test_outfile.csv'
|
||||
state = 'downloading'
|
||||
ratio = 1.05
|
||||
tags = 'ipt'
|
||||
added = 1
|
||||
age = 240000
|
||||
time = 123456
|
||||
thash = 'asfasdf23412adfqwer'
|
||||
tname = 'thisismynamehahahah'
|
||||
dragnet(self.cv,outfile,state,ratio,tags,added,age,time,thash,tname)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
@ -93,6 +93,8 @@ class TestQbitmaid(unittest.TestCase):
|
||||
def test_isignoredtag_sanity(self):
|
||||
self.assertTrue(is_ignored_tag(['a','b','c'], 'first,second,third,a'))
|
||||
|
||||
|
||||
|
||||
# def test__sanity(self):
|
||||
# pass
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user