Exemple #1
0
class TestApi(unittest.TestCase):
    def setUp(self):
        self.smugmug = SmugMug(api_key=API_KEY,
                               api_version='1.2.2',
                               app_name='TestApp')

    def test_ping(self):
        rsp = self.smugmug.service_ping()
        self.assertEqual(rsp['stat'], 'ok')

    def test_dynamic_method(self):
        self.smugmug.login_anonymously()
        rsp = self.smugmug.albums_get(NickName='test')
        self.assertEqual(rsp['method'], 'smugmug.albums.get')
        self.smugmug.reset_auth()

    def test_authorize(self):
        expected = 'http://api.smugmug.com/services/oauth/authorize.mg?oauth_token=ABC&Access=Public&Permissions=Read'
        self.smugmug.set_oauth_token('ABC', '123')
        url = self.smugmug.authorize(access='Public', perm='Read')
        self.assertEqual(url, expected)
        self.smugmug.reset_auth()

    def test_failed_api(self):
        if sys.version_info < (2, 7):
            self.assertRaises(SmugMugException,
                              lambda: self.smugmug.bad_apimethod())
        else:
            with self.assertRaises(SmugMugException):
                self.smugmug.bad_apimethod()
Exemple #2
0
class TestApi(unittest.TestCase):
    def setUp(self):
        self.smugmug = SmugMug(api_key=API_KEY, api_version='1.2.2', app_name='TestApp')

    def test_ping(self):
        rsp = self.smugmug.service_ping()
        self.assertEqual(rsp['stat'], 'ok')

    def test_dynamic_method(self):
        self.smugmug.login_anonymously()
        rsp = self.smugmug.albums_get(NickName='test')
        self.assertEqual(rsp['method'], 'smugmug.albums.get')
        self.smugmug.reset_auth()

    def test_authorize(self):
        expected = 'http://api.smugmug.com/services/oauth/authorize.mg?oauth_token=ABC&Access=Public&Permissions=Read'
        self.smugmug.set_oauth_token('ABC','123')
        url = self.smugmug.authorize(access='Public', perm='Read')
        self.assertEqual(url, expected)
        self.smugmug.reset_auth()

    def test_failed_api(self):
        if sys.version_info < (2, 7):
            self.assertRaises(SmugMugException, lambda: self.smugmug.bad_apimethod())
        else:
            with self.assertRaises(SmugMugException):
                self.smugmug.bad_apimethod()
Exemple #3
0
class TestLogin130(unittest.TestCase):
    def setUp(self):
        self.smugmug = SmugMug(api_key=API_KEY,
                               api_version='1.3.0',
                               app_name='TestApp')

    def test_login_anonymously(self):
        if sys.version_info < (2, 7):
            self.assertRaises(SmugMugException,
                              lambda: self.smugmug.login_anonymously())
        else:
            with self.assertRaises(SmugMugException):
                self.smugmug.login_anonymously()

    def test_login_withHash(self):
        if sys.version_info < (2, 7):
            self.assertRaises(
                SmugMugException,
                lambda: self.smugmug.login_withHash(UserID='test',
                                                    PasswordHash='ABCDE'))
        else:
            with self.assertRaises(SmugMugException):
                self.smugmug.login_withHash(UserID='test',
                                            PasswordHash='ABCDE')

    def test_login_withPassword(self):
        if sys.version_info < (2, 7):
            self.assertRaises(
                SmugMugException, lambda: self.smugmug.login_withPassword(
                    EmailAddress='*****@*****.**', Password='******'))
        else:
            with self.assertRaises(SmugMugException):
                self.smugmug.login_withPassword(
                    EmailAddress='*****@*****.**', Password='******')
Exemple #4
0
class TestLogin(unittest.TestCase):
    def setUp(self):
        self.smugmug = SmugMug(api_key=API_KEY, api_version='1.2.2', app_name='TestApp')

    def test_login_anonymously(self):
        self.smugmug.login_anonymously()
        self.assertNotEqual(self.smugmug.session_id, None)
        self.smugmug.reset_auth()

    def test_login_withHash(self):
        self.smugmug.login_withHash(UserID='test', PasswordHash='ABCDE')
        self.assertNotEqual(self.smugmug.session_id, None)
        self.smugmug.reset_auth()

    def test_login_withPassword(self):
        self.smugmug.login_withPassword(EmailAddress='*****@*****.**', Password='******')
        self.assertNotEqual(self.smugmug.session_id, None)
        self.smugmug.reset_auth()
Exemple #5
0
class TestLogin(unittest.TestCase):
    def setUp(self):
        self.smugmug = SmugMug(api_key=API_KEY,
                               api_version='1.2.2',
                               app_name='TestApp')

    def test_login_anonymously(self):
        self.smugmug.login_anonymously()
        self.assertNotEqual(self.smugmug.session_id, None)
        self.smugmug.reset_auth()

    def test_login_withHash(self):
        self.smugmug.login_withHash(UserID='test', PasswordHash='ABCDE')
        self.assertNotEqual(self.smugmug.session_id, None)
        self.smugmug.reset_auth()

    def test_login_withPassword(self):
        self.smugmug.login_withPassword(EmailAddress='*****@*****.**',
                                        Password='******')
        self.assertNotEqual(self.smugmug.session_id, None)
        self.smugmug.reset_auth()
Exemple #6
0
class TestLogin130(unittest.TestCase):
    def setUp(self):
        self.smugmug = SmugMug(api_key=API_KEY, api_version='1.3.0', app_name='TestApp')

    def test_login_anonymously(self):
        if sys.version_info < (2, 7):
            self.assertRaises(SmugMugException, lambda: self.smugmug.login_anonymously())
        else:
            with self.assertRaises(SmugMugException):
                self.smugmug.login_anonymously()

    def test_login_withHash(self):
        if sys.version_info < (2, 7):
            self.assertRaises(SmugMugException, lambda: self.smugmug.login_withHash(UserID='test', PasswordHash='ABCDE'))
        else:
            with self.assertRaises(SmugMugException):
                self.smugmug.login_withHash(UserID='test', PasswordHash='ABCDE')

    def test_login_withPassword(self):
        if sys.version_info < (2, 7):
            self.assertRaises(SmugMugException, lambda: self.smugmug.login_withPassword(EmailAddress='*****@*****.**', Password='******'))
        else:
            with self.assertRaises(SmugMugException):
                self.smugmug.login_withPassword(EmailAddress='*****@*****.**', Password='******')
Exemple #7
0
#!/usr/bin/env python

from smugpy import SmugMug

API_KEY = "XXXXXXXXXXXXXXXXXXXXXXXXX"

smugmug = SmugMug(api_key=API_KEY, app_name="TestApp")
smugmug.login_anonymously()
albums = smugmug.albums_get(NickName="williams") # Moon River Photography, thanks Andy!

for album in albums["Albums"]:
    print "%s, %s" % (album["id"], album["Title"])
Exemple #8
0
#!/usr/bin/env python

from smugpy import SmugMug

API_KEY = "XXXXXXXXXXXXXXXXXXXXXXXXX"

smugmug = SmugMug(api_key=API_KEY, app_name="TestApp")
smugmug.login_anonymously()
albums = smugmug.albums_get(
    NickName="williams")  # Moon River Photography, thanks Andy!

for album in albums["Albums"]:
    print "%s, %s" % (album["id"], album["Title"])