Beispiel #1
0
class TestDownloadsService(TestCase):

    def setUp(self):
        self.ds = Downloads(user='******', repo='re_oct')

    def test_LIST(self, request_method):
        request_method.return_value = mock_response_result()
        self.ds.list().all()
        self.assertEqual(request_method.call_args[0],
                         ('get', _('repos/oct/re_oct/downloads')))

    def test_GET(self, request_method):
        request_method.return_value = mock_response()
        self.ds.get(1)
        self.assertEqual(request_method.call_args[0],
                         ('get', _('repos/oct/re_oct/downloads/1')))

    def test_DELETE(self, request_method):
        request_method.return_value = mock_response('delete')
        self.ds.delete(1)
        self.assertEqual(request_method.call_args[0],
                         ('delete', _('repos/oct/re_oct/downloads/1')))

    def test_CREATE(self, request_method):
        request_method.return_value = mock_response('post')
        download = self.ds.create({'name': 'some', 'size': 100})
        self.assertEqual(request_method.call_args[0],
                         ('post', _('repos/oct/re_oct/downloads')))
        self.assertTrue(hasattr(download, 'upload'))
Beispiel #2
0
class TestDownloadsService(TestCase):
    def setUp(self):
        self.ds = Downloads(user='******', repo='re_oct')

    def test_LIST(self, request_method):
        request_method.return_value = mock_response_result()
        self.ds.list().all()
        self.assertEqual(request_method.call_args[0],
                         ('get', _('repos/oct/re_oct/downloads')))

    def test_GET(self, request_method):
        request_method.return_value = mock_response()
        self.ds.get(1)
        self.assertEqual(request_method.call_args[0],
                         ('get', _('repos/oct/re_oct/downloads/1')))

    def test_DELETE(self, request_method):
        request_method.return_value = mock_response('delete')
        self.ds.delete(1)
        self.assertEqual(request_method.call_args[0],
                         ('delete', _('repos/oct/re_oct/downloads/1')))

    def test_CREATE(self, request_method):
        request_method.return_value = mock_response('post')
        download = self.ds.create({'name': 'some', 'size': 100})
        self.assertEqual(request_method.call_args[0],
                         ('post', _('repos/oct/re_oct/downloads')))
        self.assertTrue(hasattr(download, 'upload'))
import argparse
import os
import ConfigParser

from pygithub3.services.repos import Downloads

config = ConfigParser.ConfigParser()
config.read(os.path.expanduser('~/.kickstandproject.cfg'))

login = config.get('github', 'login')
password = config.get('github', 'password')

auth = dict(login=login, password=password)

parser = argparse.ArgumentParser()
parser.add_argument('filename')
parser.add_argument('--user')
parser.add_argument('--repo')
args = parser.parse_args()

filesize = os.path.getsize(args.filename)

downloads_service = Downloads(**auth)

download = downloads_service.create(
    dict(name=args.filename, size=filesize),
    user=args.user, repo=args.repo)

x = download.upload(args.filename)
print x
Beispiel #4
0
 def setUp(self):
     self.ds = Downloads(user='******', repo='re_oct')
Beispiel #5
0
 def setUp(self):
     self.ds = Downloads(user='******', repo='re_oct')