# -*- coding:utf-8 -*-
#!/usr/bin/env python

"""
多说API测试文件。作为通用的Python程序，没有使用Django的TestCase
"""
import os
import unittest
os.sys.path.append('/home/perchouli/duoshuo-python-sdk/')

import duoshuo

class DuoshuoAPITest(unittest.TestCase):
    DUOSHUO_SHORT_NAME = 'test'
    DUOSHUO_SECRET = 'a'*64

    HOST = duoshuo.HOST
    
    def test_host(self):
        host = self.HOST
        self.assertEqual(host + 'api.duoshuo.com')


    def test_resource(self):
        pass
        #rs = duoshuo.Resource(INTERFACES)

if __name__ == '__main__':
    unittest.main()
@@ -192,16 +192,30 @@
 uoshuo%0A%0A
+import utils%0A%0A
 class Du
@@ -273,20 +273,23 @@
 NAME = '
-test
+example
 '%0A    DU
@@ -314,17 +314,15 @@
 *64%0A
-%0A
     
-HOST
+API
  = d
@@ -332,67 +332,145 @@
 huo.
-HOST%0A    %0A    def test_host(self):%0A        host = self.HOST
+DuoshuoAPI(short_name=DUOSHUO_SHORT_NAME, secret=DUOSHUO_SECRET)%0A%0A    def test_host(self):%0A        api = self.API%0A        host = api.host
 %0A   
@@ -499,10 +499,9 @@
 host
- +
+,
  'ap
@@ -535,16 +535,15 @@
 est_
-resource
+get_url
 (sel
@@ -558,54 +558,512 @@
     
-pass%0A        #rs = duoshuo.Resource(INTERFACES
+redirect_uri = 'example.com'%0A        api = self.API%0A        url = utils.get_url(api, redirect_uri=redirect_uri)%0A        print url%0A        self.assertEqual(url,%0A            'http://%25s/oauth2/authorize?client_id=%25s&redirect_uri=%25s&response_type=code' %25 %0A            ( api.host, self.DUOSHUO_SHORT_NAME, redirect_uri)%0A        )%0A%0A    def test_user_api(self):%0A        api = self.API%0A        response = api.users.details(user_id=1)%0A        user_id = response%5B'user_id'%5D%0A        self.assertEqual(int(user_id), 1
 )%0A%0Ai

test api