示例#1
0
class TestKupanAPI(unittest.TestCase):
    def setUp(self):
        sess = KuaipanSession("", "", "app_folder")
        sess.set_access_token("", "")
        self.api = KuaipanAPI(sess)

    def test_acc_info(self):
        print "================acc_info===================="
        ret = self.api.account_info()
        assert int(ret['user_id']) == 3261479

    def test_metadata(self):
        print "================meta_data==================="
        self.api.create_folder(u"/metadata文件")
        self.api.upload_file("/metadata文件/1.txt", "hello", True)
        self.api.upload_file("/metadata文件/2.txt", "world", True)
        ret = self.api.metadata(u"/metadata文件")
        assert ret['files'].__len__() == 2
        ret = self.api.metadata(u"/metadata文件/1.txt")
        assert ret['name'] == u"1.txt"

    def test_shares(self):
        print "================shares======================"
        ret = self.api.create_folder(u"/文件share/")
        assert ret['msg'] == 'ok'
        ret = self.api.upload_file(u"/文件share/1.txt", "hello world!", True)
        self.api.shares(u"/文件share/1.txt")
        try:
            print self.api.shares(u"/文件share")
        except Exception, e:
            assert e.code == 404
        else:
示例#2
0
class TestKupanAPI(unittest.TestCase):

    def setUp(self):
       sess = KuaipanSession("", "", "app_folder")
       sess.set_access_token("", "")
       self.api = KuaipanAPI(sess)

    
    def test_acc_info(self):
        print "================acc_info===================="
        ret = self.api.account_info()
        assert int(ret['user_id']) == 3261479

    def test_metadata(self):
        print "================meta_data==================="
        self.api.create_folder(u"/metadata文件")
        self.api.upload_file("/metadata文件/1.txt", "hello", True)
        self.api.upload_file("/metadata文件/2.txt", "world", True)
        ret = self.api.metadata(u"/metadata文件")
        assert ret['files'].__len__() == 2
        ret = self.api.metadata(u"/metadata文件/1.txt")
        assert ret['name'] == u"1.txt"

    def test_shares(self):
        print "================shares======================"
        ret = self.api.create_folder(u"/文件share/")
        assert ret['msg'] == 'ok'
        ret = self.api.upload_file(u"/文件share/1.txt", "hello world!", True)
        self.api.shares(u"/文件share/1.txt")
        try:
            print self.api.shares(u"/文件share")
        except Exception, e:
            assert e.code == 404
        else:
示例#3
0
class Demo():
    _consumer_key = "xcAjfAIqjOde1UAe"
    _consumer_secret = "o7M7tKvsciqpwG36"

    def __init__(self):
        sess = KuaipanSession(self._consumer_key, self._consumer_secret,
                              "app_folder")
        self.api = KuaipanAPI(sess)
        url = self.api.requestToken()
        print url
        webbrowser.open(url)
        raw_input()
        #time.sleep(30) # sleep  授权
        self.api.accessToken()

    def test_acc_info(self):
        print "================acc_info===================="
        ret = self.api.account_info()
        print ret
        print ret['user_name']

    def test_metadata(self):
        print "================meta_data==================="
        self.api.create_folder(u"/metadata文件")
        self.api.upload_file("/metadata文件/1.txt", "hello", True)
        self.api.upload_file("/metadata文件/2.txt", "world", True)
        ret = self.api.metadata(u"/metadata文件")
        assert ret['files'].__len__() == 2
        ret = self.api.metadata(u"/metadata文件/1.txt")
        assert ret['name'] == u"1.txt"

    def test_shares(self):
        print "================shares======================"
        ret = self.api.create_folder(u"/文件share/")
        assert ret['msg'] == 'ok'
        ret = self.api.upload_file(u"/文件share/1.txt", "hello world!", True)
        self.api.shares(u"/文件share/1.txt")
        try:
            print self.api.shares(u"/文件share")
        except Exception, e:
            assert e.code == 404
        else:
示例#4
0
class Demo():
    _consumer_key = "xcAjfAIqjOde1UAe"
    _consumer_secret = "o7M7tKvsciqpwG36"

    def __init__(self):
       sess = KuaipanSession(self._consumer_key, self._consumer_secret, "app_folder")
       self.api = KuaipanAPI(sess)
       url = self.api.requestToken()
       print url
       webbrowser.open(url)
       raw_input()
       #time.sleep(30) # sleep  授权
       self.api.accessToken()

    
    def test_acc_info(self):
        print "================acc_info===================="
        ret = self.api.account_info()
        print ret
        print ret['user_name']

    def test_metadata(self):
        print "================meta_data==================="
        self.api.create_folder(u"/metadata文件")
        self.api.upload_file("/metadata文件/1.txt", "hello", True)
        self.api.upload_file("/metadata文件/2.txt", "world", True)
        ret = self.api.metadata(u"/metadata文件")
        assert ret['files'].__len__() == 2
        ret = self.api.metadata(u"/metadata文件/1.txt")
        assert ret['name'] == u"1.txt"

    def test_shares(self):
        print "================shares======================"
        ret = self.api.create_folder(u"/文件share/")
        assert ret['msg'] == 'ok'
        ret = self.api.upload_file(u"/文件share/1.txt", "hello world!", True)
        self.api.shares(u"/文件share/1.txt")
        try:
            print self.api.shares(u"/文件share")
        except Exception, e:
            assert e.code == 404
        else: