def test_to_log(self): self.t1.start() assert self.t1.to_log() == '<font color="black">test-1: idle - None</font>' subject = Subject('dummy', 'http://httpbin.org/get', Downloader(), self.t1.queue) self.t1.queue.put(subject) time.sleep(.2) assert self.t1.to_log() == '<font color="green">test-1: working - dummy</font>'
def test_create_subject_folder(self): subject = Subject('test-create-folder', '', None, None) link = BaseLink('link-create-subject-folder', '', subject, subject.downloader, subject.queue) link.create_subject_folder() folder_path = os.path.join(Options.ROOT_FOLDER, 'test-create-folder') assert os.path.isdir(folder_path) shutil.rmtree(folder_path) assert not os.path.isdir(folder_path)
def p(name, url=None): if url is None: url = str(random.randint(1, 10**9)) subject = Subject(name, url, d, queue) return subject
def p(subject_name, link_name): subject = Subject(subject_name, str(random.randint(0, 10**9)), d, queue) link = BaseLink(link_name, str(random.randint(0, 10**9)), subject, d, queue) return link
def subject(d, queue): return Subject('test-subject', 'http://localhost/url-test-subject', d, queue)
def p(subject_name, link_name): subject = Subject(subject_name, str(random.randint(0, 10**9)), d, queue) resource = Delivery(link_name, str(random.randint(0, 10**9)), subject, d, queue) return resource