예제 #1
0
def _test_file(name, plugin):
    print '-'*100, "testing plugin {} with file {}".format(plugin, name)

    path = os.path.join(rootpath, name)
    with transaction:
        package = core.Package(name=os.path.splitext(name)[0], complete_dir=rootpath)
        file = core.File(package=package, name=name, url='file://{}'.format(path), host=FakeHosterPlugin(),
                         pmatch='asdf', state='download_complete')

    event.wait_for_events(['fileplugin:done'], 5)

    assert file.last_error is None
    assert file.working is False
    assert file.state == '{}_complete'.format(plugin)
    assert plugin in file.completed_plugins

    p = os.path.join(file.get_extract_path(), "1mb.bin")
    assert os.path.exists(p)

    try:
        debugtools.assert_file_checksum('md5', p, '934a5866d0a738c32f040559eccbf567')
    finally:
        os.unlink(p)

    file.delete()
예제 #2
0
def _test_file(name, plugin):
    print '-' * 100, "testing plugin {} with file {}".format(plugin, name)

    path = os.path.join(rootpath, name)
    with transaction:
        package = core.Package(name=os.path.splitext(name)[0],
                               complete_dir=rootpath)
        file = core.File(package=package,
                         name=name,
                         url='file://{}'.format(path),
                         host=FakeHosterPlugin(),
                         pmatch='asdf',
                         state='download_complete')

    event.wait_for_events(['fileplugin:done'], 5)

    assert file.last_error is None
    assert file.working is False
    assert file.state == '{}_complete'.format(plugin)
    assert plugin in file.completed_plugins

    p = os.path.join(file.get_extract_path(), "1mb.bin")
    assert os.path.exists(p)

    try:
        debugtools.assert_file_checksum('md5', p,
                                        '934a5866d0a738c32f040559eccbf567')
    finally:
        os.unlink(p)

    file.delete()
예제 #3
0
    def finish_download(self, type, speed=0):
        print "!!!", '{} #finish'.format(type)

        interface.call('config', 'set', key='download.rate_limit', value=speed)
        self.file_enabled(True)
        event.wait_for_events(['file:download_complete'], 10)
        self.assert_download_complete()
        debugtools.assert_file_checksum('md5', self.file.get_complete_file(), httpserver.md5_10mb)
        self.del_link()
예제 #4
0
def _test_rar_multipart_start_stop():
    print '-' * 100, 'test_rar_multipart_start_stop'

    files = list()
    add_files(files, 'download_complete', 'foo', 'foo')

    gevent.spawn_later(1.5, interface.call, 'core', 'stop')
    event.wait_for_events(['download:stopped'], 5)
    interface.call('core', 'printr')

    gevent.sleep(1)
    interface.call('core', 'start')
    event.wait_for_events(
        ['rarextract:part_complete', 'rarextract:waiting_for_part'], 5)
    interface.call('core', 'printr')

    with transaction:
        files[1].state = 'download_complete'

    event.wait_for_events(
        ['rarextract:part_complete', 'rarextract:waiting_for_part'], 5)
    interface.call('core', 'printr')

    with transaction:
        files[2].state = 'download_complete'

    event.wait_for_events(
        ['rarextract:part_complete', 'rarextract:waiting_for_part'], 5)
    interface.call('core', 'printr')

    gevent.sleep(0.1)
    for f in files:
        f.join()
        assert f.last_error is None
        assert f.working is False
        assert f.state == 'rarextract_complete', "expected complete, but is {}".format(
            f.state)

    p = os.path.join(files[0].get_extract_path(), "1mb.bin")
    assert os.path.exists(p)

    try:
        debugtools.assert_file_checksum('md5', p,
                                        '934a5866d0a738c32f040559eccbf567')
    finally:
        os.unlink(p)

    for f in files:
        f.delete()
예제 #5
0
def test_rar_multipart():
    print "-" * 100, 'test_rar_multipart'

    files = list()
    add_files(files, 'download_complete', 'download', 'download')

    event.wait_for_events(
        ['rarextract:part_complete', 'rarextract:waiting_for_part'], 5)
    interface.call('core', 'printr')

    with transaction:
        if not "rarextract" in files[1].completed_plugins:
            print files[1].state
            files[1].state = 'download_complete'
            files[1].working = False

    event.wait_for_events(
        ['rarextract:part_complete', 'rarextract:waiting_for_part'], 5)
    interface.call('core', 'printr')

    with transaction:
        if not "rarextract" in files[2].completed_plugins:
            print files[2].state
            files[2].state = 'download_complete'
            files[2].working = False

    event.wait_for_events(
        ['rarextract:part_complete', 'rarextract:waiting_for_part'], 5)
    interface.call('core', 'printr')

    gevent.sleep(1)
    for f in files:
        f.join()
        assert f.last_error is None
        assert not f.working, "{} is working".format(f.name)
        assert f.state == 'rarextract_complete', "expected complete, but is {}".format(
            f.state)

    p = os.path.join(files[0].get_extract_path(), "1mb.bin")
    assert os.path.exists(p)

    try:
        debugtools.assert_file_checksum('md5', p,
                                        '934a5866d0a738c32f040559eccbf567')
    finally:
        os.unlink(p)

    for f in files:
        f.delete()
예제 #6
0
def test_rar_multipart():
    print "-"*100, 'test_rar_multipart'

    files = list()
    add_files(files, 'download_complete', 'download', 'download')

    event.wait_for_events(['rarextract:part_complete', 'rarextract:waiting_for_part'], 5)
    interface.call('core', 'printr')

    with transaction:
        if not "rarextract" in files[1].completed_plugins:
            print files[1].state
            files[1].state = 'download_complete'
            files[1].working = False

    event.wait_for_events(['rarextract:part_complete', 'rarextract:waiting_for_part'], 5)
    interface.call('core', 'printr')

    with transaction:
        if not "rarextract" in files[2].completed_plugins:
            print files[2].state
            files[2].state = 'download_complete'
            files[2].working = False

    event.wait_for_events(['rarextract:part_complete', 'rarextract:waiting_for_part'], 5)
    interface.call('core', 'printr')

    gevent.sleep(1)
    for f in files:
        f.join()
        assert f.last_error is None
        assert not f.working, "{} is working".format(f.name)
        assert f.state == 'rarextract_complete', "expected complete, but is {}".format(f.state)

    p = os.path.join(files[0].get_extract_path(), "1mb.bin")
    assert os.path.exists(p)

    try:
        debugtools.assert_file_checksum('md5', p, '934a5866d0a738c32f040559eccbf567')
    finally:
        os.unlink(p)

    for f in files:
        f.delete()
예제 #7
0
def _test_rar_multipart_start_stop():
    print '-'*100, 'test_rar_multipart_start_stop'

    files = list()
    add_files(files, 'download_complete', 'foo', 'foo')

    gevent.spawn_later(1.5, interface.call, 'core', 'stop')
    event.wait_for_events(['download:stopped'], 5)
    interface.call('core', 'printr')

    gevent.sleep(1)
    interface.call('core', 'start')
    event.wait_for_events(['rarextract:part_complete', 'rarextract:waiting_for_part'], 5)
    interface.call('core', 'printr')

    with transaction:
        files[1].state = 'download_complete'

    event.wait_for_events(['rarextract:part_complete', 'rarextract:waiting_for_part'], 5)
    interface.call('core', 'printr')

    with transaction:
        files[2].state = 'download_complete'

    event.wait_for_events(['rarextract:part_complete', 'rarextract:waiting_for_part'], 5)
    interface.call('core', 'printr')

    gevent.sleep(0.1)
    for f in files:
        f.join()
        assert f.last_error is None
        assert f.working is False
        assert f.state == 'rarextract_complete', "expected complete, but is {}".format(f.state)

    p = os.path.join(files[0].get_extract_path(), "1mb.bin")
    assert os.path.exists(p)

    try:
        debugtools.assert_file_checksum('md5', p, '934a5866d0a738c32f040559eccbf567')
    finally:
        os.unlink(p)

    for f in files:
        f.delete()