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:
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)
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)
def setUp(self): self.api = API(username=p_username, password=p_password)
def test_method_twitter_auth_check(self): api = API() self.assertRaises(PyposterousError, api.test_twitter_auth_required)