working with test case data

This commit is contained in:
Jonathan Branan 2022-08-11 21:06:37 -05:00
parent f54702ceb6
commit 06b5016b90
3 changed files with 26 additions and 10 deletions

View File

@ -2,6 +2,7 @@
import qbittorrentapi
import pushover
from json import load
from json import dump
from qlist import *
from qlogging import *
from qprocess import *
@ -66,6 +67,9 @@ class Qbt:
self.torrentlist = {}
# Pulling all torrent data
self.torrentlist = self.qbt_client.torrents_info()
self.d = dump
self.l = load
writetor(self)
#Main process block
#debugpremecal(self)
if self.use_log:

View File

@ -47,12 +47,15 @@ def getunixtimestamp(self):
self.uts = self.t.time()
self.tl.info(self.uts)
def writetor(self, filepath='./torrentinfo.txt'):
def writetor(self, filepath='./torrentinfo.json'):
"""Write all torrent data to a file.
Useful for development of new features.
"""
with open(filepath, 'w') as fp:
fp.write(str(self.torrentlist))
json_init = self.l(self.torrentlist)
print(json_init)
# json_object = self.d(self.torrentlist, indent=4)
# with open(filepath, 'w') as fp:
# fp.write(json_object)
def listfirsttor(self, index=0):
"""Only lists the first torrent"""
@ -86,4 +89,7 @@ def getscriptruntime(self):
if self.use_log:
self.tl.info(f'Execution time: [{elapsed_time}]')
if self.use_pushover:
self.extm = f"Execution time: [{elapsed_time}]"
self.extm = f"Execution time: [{elapsed_time}]"
def getobjecttype(object):
print(type(object))

View File

@ -1,12 +1,18 @@
import unittest
from qprocess import torprocessor
from json import loads
import json
import logging
import sys
class TestQprocess(unittest.TestCase):
def test_protected_ratio_below(self):
self.ti = open("./test/torrentinfo.txt")
self.tracker_list = loads(self.ti)
torprocessor(self)
def test_log_and_test_data(self):
self.log= logging.getLogger( "SomeTest.testSomething" )
self.tracker_list = open("./test/torrentinfo.txt", "r")
self.log.debug(self.tracker_list)
assert self.tracker_list
# torprocessor(self)
if __name__ == '__main__':
logging.basicConfig( stream=sys.stderr )
logging.getLogger( "SomeTest.testSomething" ).setLevel( logging.DEBUG )
unittest.main()