class Test(unittest.TestCase): def setUp(self): self.persistence = Persistence('test.dat') self.persistence.remove_file() self.persistence.create_file() self.data = DotaBuffData() self.data.matches = [Match(656830280, datetime(2014, 5, 12, 18, 40), (28, 4)), Match(656759204, datetime(2014, 5, 12, 18, 0), (36,54)), Match(655653242, datetime(2014, 5, 12, 5, 10), (42,25))] def tearDown(self): self.persistence.remove_file() def testFileIsCreatedIfItDoesntExist(self): self.persistence.remove_file() self.persistence.load(self.data) self.assertTrue(self.persistence.file_exists()) def testLoad(self): self.persistence.save(self.data) retrieved_data = DotaBuffData() self.persistence.load((retrieved_data)) self.assertEqual(self.data.matches, retrieved_data.matches) self.assertEqual(3, len(retrieved_data.matches))
from cmdparser import cmdparser from dotadata.dotabuffdata import DotaBuffData from persistence.persistence import Persistence from reader.dotabuffreader import DotaBuffReader from reader.httpclient import HttpClient from reader.htmlparser import HtmlParser from task.threadmanager import ThreadManager args = cmdparser.parse() data = DotaBuffData() reader = DotaBuffReader(HttpClient(), HtmlParser()) persistence = Persistence(args.outfile) persistence.load(data) thread_manager = ThreadManager(args.thread_count, args.start_page, args.end_page) thread_manager.allocate_threads(data, reader, args.player_id) print("running...") thread_manager.start() thread_manager.join() for match in thread_manager.found_matches: print("match: {0}, {1}, {2}:{3:02d}".format(match.match_id, match.datetime, match.duration[0], match.duration[1])) print("done.") persistence.save(data)