Example #1
0
    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>'
Example #2
0
    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)
Example #3
0
 def p(name, url=None):
     if url is None:
         url = str(random.randint(1, 10**9))
     subject = Subject(name, url, d, queue)
     return subject
Example #4
0
 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
Example #5
0
def subject(d, queue):
    return Subject('test-subject', 'http://localhost/url-test-subject', d,
                   queue)
Example #6
0
 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