Exemplo n.º 1
0
def test_torrent_get_files(tr_client: Client):
    with open("tests/fixtures/iso.torrent", "rb") as f:
        tr_client.add_torrent(f)
    assert len(tr_client.get_torrents()) == 1, "transmission should has at least 1 task"
    for torrent in tr_client.get_torrents():
        for file in torrent.files():
            assert isinstance(file, File)
Exemplo n.º 2
0
def test_torrent_start_all(tr_client: Client, fake_hash_factory):
    tr_client.add_torrent(hash_to_magnet(fake_hash_factory()), paused=True, timeout=1)
    tr_client.add_torrent(hash_to_magnet(fake_hash_factory()), paused=True, timeout=1)
    for torrent in tr_client.get_torrents():
        assert torrent.status == 'stopped', 'all torrent should be stopped'

    tr_client.start_all()
    for torrent in tr_client.get_torrents():
        assert torrent.status == 'downloading', 'all torrent should be downloading'
Exemplo n.º 3
0
def test_real_stop(tr_client: Client, fake_hash_factory):
    info_hash = fake_hash_factory()
    url = hash_to_magnet(info_hash)
    tr_client.add_torrent(url)
    tr_client.stop_torrent(info_hash)
    assert len(tr_client.get_torrents()) == 1, 'transmission should has only 1 task'
    ret = False

    for _ in range(50):
        time.sleep(0.2)
        if tr_client.get_torrents()[0].status == 'stopped':
            ret = True
            break

    assert ret, 'torrent should be stopped'
Exemplo n.º 4
0
def test_real_add_torrent_file_protocol(tr_client: Client):
    fs = os.path.abspath(
        os.path.join(
            os.path.dirname(__file__, ),
            "fixtures/iso.torrent",
        ))
    tr_client.add_torrent("file://" + fs)
    assert len(tr_client.get_torrents()
               ) == 1, "transmission should has at least 1 task"
Exemplo n.º 5
0
def test_real_get_files(tr_client: Client):
    with open("tests/fixtures/iso.torrent", "rb") as f:
        tr_client.add_torrent(f)
    assert len(tr_client.get_torrents()) == 1, "transmission should has at least 1 task"
    for tid, files in tr_client.get_files(1).items():
        assert files
        assert isinstance(tid, int)
        for file in files:
            assert isinstance(file, File)
Exemplo n.º 6
0
def test_real_add_torrent_base64(tr_client: Client):
    with open("tests/fixtures/iso.torrent", "rb") as f:
        tr_client.add_torrent(base64.b64encode(f.read()).decode())
    assert len(tr_client.get_torrents()
               ) == 1, "transmission should has at least 1 task"
Exemplo n.º 7
0
def test_real_add_torrent_fd(tr_client: Client):
    with open("tests/fixtures/iso.torrent", "rb") as f:
        tr_client.add_torrent(f)
    assert len(tr_client.get_torrents()
               ) == 1, "transmission should has at least 1 task"
Exemplo n.º 8
0
def test_real_add_magnet(tr_client: Client):
    tr_client.add_torrent(magnet_url)
    assert len(tr_client.get_torrents()
               ) == 1, "transmission should has at least 1 task"
Exemplo n.º 9
0
def test_torrent_attr_type(tr_client: Client, fake_hash_factory):
    with open("tests/fixtures/iso.torrent", "rb") as f:
        tr_client.add_torrent(f)
    for torrent in tr_client.get_torrents():
        assert isinstance(torrent.id, int)
        assert isinstance(torrent.name, str)
Exemplo n.º 10
0
def test_real_add_torrent_not_endswith_torrent(tr_client: Client):
    # The shorten url is ref to
    # "https://github.com/Trim21/transmission-rpc/raw/master/tests/fixtures/iso.torrent"
    tr_client.add_torrent("https://git.io/JJUVt")
    assert len(tr_client.get_torrents()
               ) == 1, "transmission should has at least 1 task"
Exemplo n.º 11
0
def test_real_add_torrent_http(tr_client: Client):
    tr_client.add_torrent(
        "https://github.com/Trim21/transmission-rpc/raw/master/tests/fixtures/iso.torrent"
    )
    assert len(tr_client.get_torrents()
               ) == 1, "transmission should has at least 1 task"
Exemplo n.º 12
0
def test_real_add_torrent_http(tr_client: Client):
    tr_client.add_torrent(
        'https://releases.ubuntu.com/20.04/ubuntu-20.04-desktop-amd64.iso.torrent'
    )
    assert len(tr_client.get_torrents()) == 1, 'transmission should has at least 1 task'
Exemplo n.º 13
0
def test_real_add_magnet(tr_client: Client):
    torrent_url = 'magnet:?xt=urn:btih:e84213a794f3ccd890382a54a64ca68b7e925433'
    tr_client.add_torrent(torrent_url)
    assert len(tr_client.get_torrents()
               ) == 1, 'transmission should has at least 1 task'
Exemplo n.º 14
0
def test_real_add_torrent_base64(tr_client: Client):
    with open("tests/fixtures/iso.torrent", "rb") as f:
        with pytest.warns(DeprecationWarning, match="base64"):
            tr_client.add_torrent(base64.b64encode(f.read()).decode())
    assert len(tr_client.get_torrents()) == 1, "transmission should has at least 1 task"