示例#1
0
 def test_download_proapi(self):
     # Clean up all files in the downloads directory
     downloads_directory = self.api.downloads_directory
     entries = downloads_directory.list()
     delete_entries(entries)
     # Upload a file
     uploaded_file = self.api.upload(TEST_UPLOAD_FILE)
     assert isinstance(uploaded_file, File)
     time.sleep(5)
     entries = downloads_directory.list()
     assert entries
     entry = entries[0]
     entry.download(path=pjoin(DOWNLOADS_DIR), proapi=True)
     delete_entries(entries)
示例#2
0
 def test_download_proapi(self):
     # Clean up all files in the downloads directory
     downloads_directory = self.api.downloads_directory
     entries = downloads_directory.list()
     delete_entries(entries)
     # Upload a file
     uploaded_file = self.api.upload(TEST_UPLOAD_FILE)
     assert isinstance(uploaded_file, File)
     time.sleep(5)
     entries = downloads_directory.list()
     assert entries
     entry = entries[0]
     entry.download(path=pjoin(DOWNLOADS_DIR), proapi=True)
     delete_entries(entries)
示例#3
0
import sys
import time
from unittest import TestCase
from u115.api import API, Torrent, Directory, File, TaskError
from u115.utils import pjoin
from u115 import conf

PY3 = sys.version_info[0] == 3
if PY3:
    from unittest.mock import Mock
else:
    from mock import Mock

LARGE_COUNT = 999
SMALL_COUNT = 2
TEST_DIR = pjoin(conf.PROJECT_PATH, 'tests')
DATA_DIR = pjoin(TEST_DIR, 'data')
DOWNLOADS_DIR = pjoin(TEST_DIR, 'downloads')

# This torrent's directory contains a single file
TEST_TORRENT1 = {
    'filename': pjoin(DATA_DIR, u'SAOII_10.torrent'),
    'info_hash': '6bcc605d8fd8629b4df92202d554e5812e78df25',
}

# This torrent's directory contains files and directories
# - BK/
#   - (11 files)
# - MP3/
#   - Disc_1/
#     - (23 files)
示例#4
0
# -*- coding: utf-8 -*-
from __future__ import print_function, absolute_import

try:
    import configparser
except ImportError:
    import ConfigParser as configparser
import os
import logging
from u115.utils import pjoin, eval_path

_d = os.path.dirname(__file__)
user_dir = eval_path('~')
PROJECT_PATH = os.path.abspath(pjoin(_d, os.pardir))
PROJECT_CREDENTIALS = pjoin(PROJECT_PATH, '.credentials')
USER_CREDENTIALS = pjoin(user_dir, '.115')
CREDENTIALS = None
COOKIES_FILENAME = pjoin(user_dir, '.115cookies')

LOGGING_API_LOGGER = 'API'
LOGGING_FORMAT = "%(levelname)s:%(name)s:%(funcName)s: %(message)s"
LOGGING_LEVEL = logging.ERROR
DEBUG_REQ_FMT = """
  TYPE: Request
  FUNC: %s
   URL: %s
METHOD: %s
PARAMS: %s
  DATA: %s
"""
示例#5
0
import time
from unittest import TestCase
from u115.api import API, Torrent, Directory, File, TaskError
from u115.utils import pjoin
from u115 import conf

PY3 = sys.version_info[0] == 3
if PY3:
    from unittest.mock import Mock
else:
    from mock import Mock


LARGE_COUNT = 999
SMALL_COUNT = 2
TEST_DIR = pjoin(conf.PROJECT_PATH, 'tests')
DATA_DIR = pjoin(TEST_DIR, 'data')
DOWNLOADS_DIR = pjoin(TEST_DIR, 'downloads')

# This torrent's directory contains a single file
TEST_TORRENT1 = {
    'filename': pjoin(DATA_DIR, u'SAOII_10.torrent'),
    'info_hash': '6bcc605d8fd8629b4df92202d554e5812e78df25',
}

# This torrent's directory contains files and directories
# - BK/
#   - (11 files)
# - MP3/
#   - Disc_1/
#     - (23 files)
示例#6
0
# -*- coding: utf-8 -*-
from __future__ import print_function, absolute_import

try:
    import configparser
except ImportError:
    import ConfigParser as configparser
import os
from u115.utils import pjoin, eval_path

_d = os.path.dirname(__file__)
user_dir = eval_path('~')
PROJECT_PATH = os.path.abspath(pjoin(_d, os.pardir))
PROJECT_CREDENTIALS = pjoin(PROJECT_PATH, '.credentials')
USER_CREDENTIALS = pjoin(user_dir, '.115')
CREDENTIALS = None

if os.path.exists(PROJECT_CREDENTIALS):
    CREDENTIALS = PROJECT_CREDENTIALS
elif os.path.exists(USER_CREDENTIALS):
    CREDENTIALS = USER_CREDENTIALS

config = configparser.ConfigParser()


def get_credential(section='default'):
    if os.environ.get('TRAVIS_TEST'):
        username = os.environ.get('TEST_USER_USERNAME')
        password = os.environ.get('TEST_USER_PASSWORD')
        if username is None or password is None:
            msg = 'No credentials environment variables found.'
示例#7
0
# -*- coding: utf-8 -*-
import time
from unittest import TestCase
from u115.api import API, Torrent, Directory, File, TaskError
from u115.utils import pjoin
from u115 import conf


LARGE_COUNT = 999
SMALL_COUNT = 2
TEST_DIR = pjoin(conf.PROJECT_PATH, 'tests')
DATA_DIR = pjoin(TEST_DIR, 'data')
TEST_TORRENT1 = {
    'filename': pjoin(DATA_DIR, u'SAOII_10.torrent'),
    'info_hash': '6bcc605d8fd8629b4df92202d554e5812e78df25',
}

TEST_TORRENT2 = {
    'filename': pjoin(DATA_DIR, u'Rozen_Maiden_OST.torrent'),
    'info_hash': 'd1fc55cc7547881884d01c56ffedd92d39d48847',
}

TEST_TARGET_URL = 'https://lh6.googleusercontent.com/-3Xz3dFlEzMs\
    /AAAAAAAAAAI/AAAAAAAAA20/RsPzPBYr4Wg/photo.jpg'


class TestAPI(TestCase):
    def __init__(self, *args, **kwargs):
        super(TestAPI, self).__init__(*args, **kwargs)
        self.api = API()
        self.api.login(section='test')