示例#1
0
class PyposterousAPITests(unittest.TestCase):    
    def setUp(self):
        self.api = API(username=p_username, password=p_password)
    
    def test_method_creation(self):                
        for app_type in METHODS:
            for method in METHODS.get(app_type):
                self.assertTrue(hasattr(getattr(self.api, method), '__call__'))
                
    def test_method_required_params(self):
        # Has a required param
        try:
            self.api.test()
        except TypeError, e:
            if not "%s" % e == "'id' is required.":
                raise
        else:
示例#2
0
class PyposterousAPITests(unittest.TestCase):
    def setUp(self):
        self.api = API(username=p_username, password=p_password)

    def test_method_creation(self):
        for app_type in METHODS:
            for method in METHODS.get(app_type):
                self.assertTrue(hasattr(getattr(self.api, method), '__call__'))

    def test_method_required_params(self):
        # Has a required param
        try:
            self.api.test()
        except TypeError, e:
            if not "%s" % e == "'id' is required.":
                raise
        else:
示例#3
0
 def test_upload(self):
     from pyposterous.auth import TwitterAuth
     
     api = API(auth=TwitterAuth(consumer_key, consumer_secret, user_key, user_secret))
     
     images = [open('test_assets/1.jpg'), open('test_assets/2.jpg'),]
     title = 'Check out this awesome media'
     body = 'AWESOME.'
     source = 'Pyposterous'
     sourceLink = 'http://github.com/thomasw/pyposterous'
     
     post = api.upload(images, title, body, source, sourceLink)
     
     retrieved = api.get_post(post.id)
     
     self.assertEqual(title, retrieved.title)
     self.assertEqual(len(retrieved.media), len(images))
     self.assertEqual(retrieved.title, post.text)
示例#4
0
    def test_upload(self):
        from pyposterous.auth import TwitterAuth

        api = API(auth=TwitterAuth(consumer_key, consumer_secret, user_key,
                                   user_secret))

        images = [
            open('test_assets/1.jpg'),
            open('test_assets/2.jpg'),
        ]
        title = 'Check out this awesome media'
        body = 'AWESOME.'
        source = 'Pyposterous'
        sourceLink = 'http://github.com/thomasw/pyposterous'

        post = api.upload(images, title, body, source, sourceLink)

        retrieved = api.get_post(post.id)

        self.assertEqual(title, retrieved.title)
        self.assertEqual(len(retrieved.media), len(images))
        self.assertEqual(retrieved.title, post.text)
示例#5
0
 def setUp(self):
     self.api = API(username=p_username, password=p_password)
示例#6
0
 def setUp(self):
     self.api = API(username=p_username, password=p_password)
示例#7
0
 def test_method_twitter_auth_check(self):
     api = API()
     self.assertRaises(PyposterousError, api.test_twitter_auth_required)