当前位置: 首页>>代码示例>>Python>>正文


Python AWeberAPI.load_from_url方法代码示例

本文整理汇总了Python中aweber_api.AWeberAPI.load_from_url方法的典型用法代码示例。如果您正苦于以下问题:Python AWeberAPI.load_from_url方法的具体用法?Python AWeberAPI.load_from_url怎么用?Python AWeberAPI.load_from_url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在aweber_api.AWeberAPI的用法示例。


在下文中一共展示了AWeberAPI.load_from_url方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TestAWeberCollection

# 需要导入模块: from aweber_api import AWeberAPI [as 别名]
# 或者: from aweber_api.AWeberAPI import load_from_url [as 别名]
class TestAWeberCollection(TestCase):

    def setUp(self):
        self.aweber = AWeberAPI('1', '2')
        self.aweber.adapter = MockAdapter()
        self.lists = self.aweber.load_from_url('/accounts/1/lists')
        self.aweber.adapter.requests = []

    def test_should_be_a_collection(self):
        self.assertTrue(type(self.lists), AWeberCollection)

    def test_should_have_24_lists(self):
        self.assertTrue(len(self.lists), 24)

    def test_should_be_able_get_each_via_offset(self):
        for i in range(0, 23):
            list = self.lists[i]
            self.assertEqual(type(list), AWeberEntry)
            self.assertEqual(list.type, 'list')

    def test_should_be_able_to_iterate_on_collection(self):
        list_number = 0
        for list in self.lists:
            self.assertEqual(type(list), AWeberEntry)
            self.assertEqual(list.type, 'list')
            list_number += 1
        self.assertEqual(list_number, 24)

    def test_should_support_get_by_id(self):
        list = self.lists.get_by_id(303449)
        self.assertEqual(type(list), AWeberEntry)
        self.assertEqual(list.type, 'list')
        self.assertEqual(list.id, 303449)

    def test_should_support_find_method(self):
        base_url = '/accounts/1/lists/303449/subscribers'
        subscriber_collection = self.aweber.load_from_url(base_url)
        self.aweber.adapter.requests = []
        subscribers = subscriber_collection.find(email='[email protected]')
        request = self.aweber.adapter.requests[0]

        assert subscribers != False
        assert isinstance(subscribers, AWeberCollection)
        assert len(subscribers) == 1
        assert subscribers[0].self_link == \
                'https://api.aweber.com/1.0/accounts/1/lists/303449/subscribers/50205517'
        assert request['url'] == \
            '{0}?ws.op=find&email=joe%40example.com'.format(base_url)

    def test_find_should_handle_errors(self):
        base_url = '/accounts/1/lists/303449/subscribers'
        subscriber_collection = self.aweber.load_from_url(base_url)
        self.assertRaises(APIException, subscriber_collection.find, name='joe')

    def test_should_create_entries_with_correct_url(self):
        base_url = '/accounts/1'
        account = self.aweber.load_from_url(base_url)
        subscribers = account.findSubscribers(email='[email protected]')
        for subscriber in subscribers:
            assert subscriber.url == subscriber.self_link.replace(API_BASE, '')
开发者ID:aweber,项目名称:AWeber-API-Python-Library,代码行数:62,代码来源:test_aweber_collection.py

示例2: TestGettingParentEntry

# 需要导入模块: from aweber_api import AWeberAPI [as 别名]
# 或者: from aweber_api.AWeberAPI import load_from_url [as 别名]
class TestGettingParentEntry(TestCase):

    def setUp(self):
        self.aweber = AWeberAPI('1', '2')
        self.aweber.adapter = MockAdapter()
        self.list = self.aweber.load_from_url('/accounts/1/lists/303449')
        self.account = self.aweber.load_from_url('/accounts/1')
        self.custom_field = self.aweber.load_from_url('/accounts/1/lists/303449/custom_fields/1')

    def test_should_be_able_get_parent_entry(self):
        entry = self.list.get_parent_entry()

    def test_list_parent_should_be_account(self):
        entry = self.list.get_parent_entry()
        self.assertEqual(type(entry), AWeberEntry)
        self.assertEqual(entry.type, 'account')

    def test_custom_field_parent_should_be_list(self):
        entry = self.custom_field.get_parent_entry()
        self.assertEqual(type(entry), AWeberEntry)
        self.assertEqual(entry.type, 'list')

    def test_account_parent_should_be_none(self):
        entry = self.account.get_parent_entry()
        self.assertEqual(entry, None)
开发者ID:aweber,项目名称:AWeber-API-Python-Library,代码行数:27,代码来源:test_aweber_entry.py

示例3: TestMovingSubscribers

# 需要导入模块: from aweber_api import AWeberAPI [as 别名]
# 或者: from aweber_api.AWeberAPI import load_from_url [as 别名]
class TestMovingSubscribers(TestCase):

    def setUp(self):
        self.aweber = AWeberAPI('1', '2')
        self.aweber.adapter = MockAdapter()
        subscriber_url = '/accounts/1/lists/303449/subscribers/1'
        new_list_url = '/accounts/1/lists/505454'
        self.subscriber = self.aweber.load_from_url(subscriber_url)
        self.subscriber._diff['name'] = 'Joe Schmoe'
        self.list = self.aweber.load_from_url(new_list_url)
        self.move_subscriber()

    def move_subscriber(self, **kwargs):
        self.aweber.adapter.requests = []
        self.resp = self.subscriber.move(self.list, **kwargs)
        self.move_req = self.aweber.adapter.requests[0]
        self.get_req = self.aweber.adapter.requests[1]

    def test_returned_true(self):
        self.assertTrue(self.resp)

    def test_should_have_requested_move_with_post(self):
        self.assertEqual(self.move_req['method'], 'POST')

    def test_should_have_requested_move_on_subscriber(self):
        self.assertEqual(self.move_req['url'] , self.subscriber.url)

    def test_should_have_requested_move_with_correct_parameters(self):
        expected_params = {'ws.op': 'move', 'list_link': self.list.self_link}
        self.assertEqual(self.move_req['data'], expected_params)

    def test_should_make_two_requests(self):
        self.assertEqual(len(self.aweber.adapter.requests), 2)

    def test_should_refresh_subscriber_resource(self):
        self.assertEqual(self.get_req['method'], 'GET')
        self.assertEqual(self.get_req['url'] ,
            '/accounts/1/lists/505454/subscribers/3')

    def test_should_reset_diff(self):
        self.assertEqual(self.subscriber._diff, {})

    def test_should_accept_last_followup_message_number_sent(self):
        self.move_subscriber(last_followup_message_number_sent=999)
        expected_params = {'ws.op': 'move', 'list_link': self.list.self_link,
                           'last_followup_message_number_sent': 999}

        self.assertEqual(self.move_req['data'], expected_params)
开发者ID:aweber,项目名称:AWeber-API-Python-Library,代码行数:50,代码来源:test_aweber_entry.py

示例4: TestCreateMethod

# 需要导入模块: from aweber_api import AWeberAPI [as 别名]
# 或者: from aweber_api.AWeberAPI import load_from_url [as 别名]
class TestCreateMethod(TestCase):

    def setUp(self):
        self.aweber = AWeberAPI('1', '2')
        self.aweber.adapter = MockAdapter()
        url = '/accounts/1/lists/303449/any_collection'
        self.any_collection = self.aweber.load_from_url(url)

        self.aweber.adapter.requests = []
        self.resp = self.any_collection.create(
            a_string='Bob', a_dict={'Color': 'blue'}, a_list=['apple'])
        self.create_req = self.aweber.adapter.requests[0]
        self.get_req = self.aweber.adapter.requests[1]

    def test_should_make_request_with_correct_parameters(self):
        expected_params = {'ws.op': 'create', 'a_string': 'Bob',
                           'a_dict': json.dumps({'Color': 'blue'}),
                           'a_list': json.dumps(['apple'])}

        self.assertEqual(self.create_req['data'], expected_params)

    def test_should_make_two_requests(self):
        self.assertEqual(len(self.aweber.adapter.requests), 2)

    def test_should_have_requested_create_on_cf(self):
        self.assertEqual(self.create_req['url'] , self.any_collection.url)

    def test_should_have_requested_create_with_post(self):
        self.assertEqual(self.create_req['method'], 'POST')

    def test_should_refresh_created_resource(self):
        self.assertEqual(self.get_req['method'], 'GET')
        self.assertEqual(self.get_req['url'] ,
            '/accounts/1/lists/303449/any_collection/1')
开发者ID:aweber,项目名称:AWeber-API-Python-Library,代码行数:36,代码来源:test_aweber_collection.py

示例5: TestAWeberCollection

# 需要导入模块: from aweber_api import AWeberAPI [as 别名]
# 或者: from aweber_api.AWeberAPI import load_from_url [as 别名]
class TestAWeberCollection(TestCase):

    def setUp(self):
        self.aweber = AWeberAPI('1', '2')
        self.aweber.adapter = MockAdapter()
        self.lists = self.aweber.load_from_url('/accounts/1/lists')

    def test_should_be_a_collection(self):
        self.assertTrue(type(self.lists), AWeberCollection)

    def test_should_have_24_lists(self):
        self.assertTrue(len(self.lists), 24)

    def test_should_be_able_get_each_via_offset(self):
        for i in range(0, 23):
            list = self.lists[i]
            self.assertEqual(type(list), AWeberEntry)
            self.assertEqual(list.type, 'list')

    def test_should_be_able_to_iterate_on_collection(self):
        list_number = 0
        for list in self.lists:
            self.assertEqual(type(list), AWeberEntry)
            self.assertEqual(list.type, 'list')
            list_number += 1
        self.assertEqual(list_number, 24)

    def test_should_support_get_by_id(self):
        list = self.lists.get_by_id(303449)
        self.assertEqual(type(list), AWeberEntry)
        self.assertEqual(list.type, 'list')
        self.assertEqual(list.id, 303449)
开发者ID:RamosAlvarez,项目名称:AWeber-API-Python-Library,代码行数:34,代码来源:test_aweber_collection.py

示例6: SubscriberTestCase

# 需要导入模块: from aweber_api import AWeberAPI [as 别名]
# 或者: from aweber_api.AWeberAPI import load_from_url [as 别名]
class SubscriberTestCase(TestCase):

    def setUp(self):
        self.aweber = AWeberAPI('1', '2')
        self.aweber.adapter = MockAdapter()
        sub_url = '/accounts/1/lists/303449/subscribers/1'
        self.subscriber = self.aweber.load_from_url(sub_url)
开发者ID:aweber,项目名称:AWeber-API-Python-Library,代码行数:9,代码来源:test_aweber_entry.py

示例7: TestMovingSubscribers

# 需要导入模块: from aweber_api import AWeberAPI [as 别名]
# 或者: from aweber_api.AWeberAPI import load_from_url [as 别名]
class TestMovingSubscribers(TestCase):
    def setUp(self):
        self.aweber = AWeberAPI("1", "2")
        self.aweber.adapter = MockAdapter()
        subscriber_url = "/accounts/1/lists/303449/subscribers/1"
        new_list_url = "/accounts/1/lists/505454"
        self.subscriber = self.aweber.load_from_url(subscriber_url)
        self.subscriber._diff["name"] = "Joe Schmoe"
        self.list = self.aweber.load_from_url(new_list_url)
        self.move_subscriber()

    def move_subscriber(self, **kwargs):
        self.aweber.adapter.requests = []
        self.resp = self.subscriber.move(self.list, **kwargs)
        self.move_req = self.aweber.adapter.requests[0]
        self.get_req = self.aweber.adapter.requests[1]

    def test_returned_true(self):
        self.assertTrue(self.resp)

    def test_should_have_requested_move_with_post(self):
        self.assertEqual(self.move_req["method"], "POST")

    def test_should_have_requested_move_on_subscriber(self):
        self.assertEqual(self.move_req["url"], self.subscriber.url)

    def test_should_have_requested_move_with_correct_parameters(self):
        expected_params = {"ws.op": "move", "list_link": self.list.self_link}
        self.assertEqual(self.move_req["data"], expected_params)

    def test_should_make_two_requests(self):
        self.assertEqual(len(self.aweber.adapter.requests), 2)

    def test_should_refresh_subscriber_resource(self):
        self.assertEqual(self.get_req["method"], "GET")
        self.assertEqual(self.get_req["url"], "/accounts/1/lists/505454/subscribers/3")

    def test_should_reset_diff(self):
        self.assertEqual(self.subscriber._diff, {})

    def test_should_accept_last_followup_message_number_sent(self):
        self.move_subscriber(last_followup_message_number_sent=999)
        expected_params = {"ws.op": "move", "list_link": self.list.self_link, "last_followup_message_number_sent": 999}

        self.assertEqual(self.move_req["data"], expected_params)
开发者ID:hanep14,项目名称:AWeber-API-Python-Library,代码行数:47,代码来源:test_aweber_entry.py

示例8: TestFailedSubscriberDelete

# 需要导入模块: from aweber_api import AWeberAPI [as 别名]
# 或者: from aweber_api.AWeberAPI import load_from_url [as 别名]
class TestFailedSubscriberDelete(TestCase):
    def setUp(self):
        self.aweber = AWeberAPI("1", "2")
        self.aweber.adapter = MockAdapter()
        sub_url = "/accounts/1/lists/303449/subscribers/2"
        self.subscriber = self.aweber.load_from_url(sub_url)

    def test_should_raise_exception_when_failing(self):
        self.assertRaises(APIException, self.subscriber.delete)
开发者ID:hanep14,项目名称:AWeber-API-Python-Library,代码行数:11,代码来源:test_aweber_entry.py

示例9: TestSavingInvalidSubscriberData

# 需要导入模块: from aweber_api import AWeberAPI [as 别名]
# 或者: from aweber_api.AWeberAPI import load_from_url [as 别名]
class TestSavingInvalidSubscriberData(TestCase):
    def setUp(self):
        self.aweber = AWeberAPI("1", "2")
        self.aweber.adapter = MockAdapter()
        sub_url = "/accounts/1/lists/303449/subscribers/2"
        self.subscriber = self.aweber.load_from_url(sub_url)
        self.subscriber.name = "Gary Oldman"
        self.subscriber.custom_fields["New Custom Field"] = "Cookies"

    def test_save_failed(self):
        self.assertRaises(APIException, self.subscriber.save)
开发者ID:hanep14,项目名称:AWeber-API-Python-Library,代码行数:13,代码来源:test_aweber_entry.py

示例10: TestWhenCreatingCustomFieldsFails

# 需要导入模块: from aweber_api import AWeberAPI [as 别名]
# 或者: from aweber_api.AWeberAPI import load_from_url [as 别名]
class TestWhenCreatingCustomFieldsFails(TestCase):

    def setUp(self):
        self.aweber = AWeberAPI('1', '2')
        self.aweber.adapter = MockAdapter()
        cf_url = '/accounts/1/lists/505454/custom_fields'
        self.cf = self.aweber.load_from_url(cf_url)
        self.aweber.adapter.requests = []

    def test_should_raise_exception(self):
        self.assertRaises(APIException, self.cf.create, name='Duplicate Name')
开发者ID:aweber,项目名称:AWeber-API-Python-Library,代码行数:13,代码来源:test_aweber_collection.py

示例11: TestAWeberAccountEntry

# 需要导入模块: from aweber_api import AWeberAPI [as 别名]
# 或者: from aweber_api.AWeberAPI import load_from_url [as 别名]
class TestAWeberAccountEntry(TestCase):

    def setUp(self):
        self.aweber = AWeberAPI('1', '2')
        self.aweber.adapter = MockAdapter()
        self.account = self.aweber.load_from_url('/accounts/1')

    def test_should_be_an_entry(self):
        self.assertEqual(type(self.account), AWeberEntry)
        self.assertEqual(self.account.type, 'account')

    def test_should_be_able_get_web_forms(self):
        forms = self.account.get_web_forms()
开发者ID:russpos,项目名称:AWeber-API-Python-Library,代码行数:15,代码来源:test_aweber_entry.py

示例12: TestFailedSubscriberDelete

# 需要导入模块: from aweber_api import AWeberAPI [as 别名]
# 或者: from aweber_api.AWeberAPI import load_from_url [as 别名]
class TestFailedSubscriberDelete(TestCase):

    def setUp(self):
        self.aweber = AWeberAPI('1', '2')
        self.aweber.adapter = MockAdapter()
        sub_url = '/accounts/1/lists/303449/subscribers/2'
        self.subscriber = self.aweber.load_from_url(sub_url)
        self.aweber.adapter.requests = []
        self.response = self.subscriber.delete()
        self.req = self.aweber.adapter.requests[0]

    def test_should_have_failed(self):
        self.assertFalse(self.response)
开发者ID:russpos,项目名称:AWeber-API-Python-Library,代码行数:15,代码来源:test_aweber_entry.py

示例13: TestAWeberEntry

# 需要导入模块: from aweber_api import AWeberAPI [as 别名]
# 或者: from aweber_api.AWeberAPI import load_from_url [as 别名]
class TestAWeberEntry(TestCase):
    def setUp(self):
        self.aweber = AWeberAPI("1", "2")
        self.aweber.adapter = MockAdapter()
        self.list = self.aweber.load_from_url("/accounts/1/lists/303449")

    def test_should_be_an_entry(self):
        self.assertEqual(type(self.list), AWeberEntry)
        self.assertEqual(self.list.type, "list")

    def test_should_have_id(self):
        self.assertEqual(self.list.id, 303449)

    def test_should_have_other_properties(self):
        self.assertEqual(self.list.name, "default303449")

    def test_should_have_child_collections(self):
        campaigns = self.list.campaigns
        self.assertEqual(type(campaigns), AWeberCollection)

    def test_findSubscribers_should_handle_errors(self):
        account = self.aweber.load_from_url("/accounts/1")
        self.assertRaises(APIException, account.findSubscribers, name="bob")
开发者ID:hanep14,项目名称:AWeber-API-Python-Library,代码行数:25,代码来源:test_aweber_entry.py

示例14: TestCreatingCustomFields

# 需要导入模块: from aweber_api import AWeberAPI [as 别名]
# 或者: from aweber_api.AWeberAPI import load_from_url [as 别名]
class TestCreatingCustomFields(TestCase):

    def setUp(self):
        self.aweber = AWeberAPI('1', '2')
        self.aweber.adapter = MockAdapter()
        cf_url = '/accounts/1/lists/303449/custom_fields'
        self.cf = self.aweber.load_from_url(cf_url)

        self.aweber.adapter.requests = []
        self.resp = self.cf.create(name='Wedding Song')
        self.create_req = self.aweber.adapter.requests[0]
        self.get_req = self.aweber.adapter.requests[1]

    def test_should_return_new_resource_entry_object(self):
        assert isinstance(self.resp, AWeberEntry)
        assert self.resp.name == u'COLOR'
        assert self.resp.is_subscriber_updateable == True
        assert self.resp.id == 2
        assert self.resp.url == '/accounts/1/lists/303449/custom_fields/2'
开发者ID:aweber,项目名称:AWeber-API-Python-Library,代码行数:21,代码来源:test_aweber_collection.py

示例15: TestAWeberEntry

# 需要导入模块: from aweber_api import AWeberAPI [as 别名]
# 或者: from aweber_api.AWeberAPI import load_from_url [as 别名]
class TestAWeberEntry(TestCase):

    def setUp(self):
        self.aweber = AWeberAPI('1', '2')
        self.aweber.adapter = MockAdapter()
        self.list = self.aweber.load_from_url('/accounts/1/lists/303449')

    def test_should_be_an_entry(self):
        self.assertEqual(type(self.list), AWeberEntry)
        self.assertEqual(self.list.type, 'list')

    def test_should_have_id(self):
        self.assertEqual(self.list.id, 303449)

    def test_should_have_other_properties(self):
        self.assertEqual(self.list.name, 'default303449')

    def test_should_have_child_collections(self):
        campaigns = self.list.campaigns
        self.assertEqual(type(campaigns), AWeberCollection)
开发者ID:russpos,项目名称:AWeber-API-Python-Library,代码行数:22,代码来源:test_aweber_entry.py


注:本文中的aweber_api.AWeberAPI.load_from_url方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。