Skip to content
This repository was archived by the owner on Aug 29, 2019. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 24 additions & 18 deletions tests/test_aweber_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,27 +38,26 @@ def test_findSubscribers_should_handle_errors(self):
assert request['url'] == \
'{0}?ws.op=findSubscribers&name=bob'.format(base_url)

class TestAWeberAccountEntry(TestCase):

class AccountTestCase(TestCase):

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


class TestAWeberAccountEntry(AccountTestCase):

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()

def test_should_be_able_get_web_form_split_tests(self):
forms = self.account.get_web_form_split_tests()

class TestAccountGetWebForms(TestAWeberAccountEntry):
class TestAccountGetWebForms(AccountTestCase):

def setUp(self):
TestAWeberAccountEntry.setUp(self)
super(TestAccountGetWebForms, self).setUp()
self.forms = self.account.get_web_forms()

def test_should_be_a_list(self):
Expand All @@ -77,10 +76,11 @@ def test_each_should_have_correct_url(self):
for entry in self.forms:
self.assertTrue(re.match(url_regex, entry.url))

class TestAccountGetWebFormSplitTests(TestAWeberAccountEntry):

class TestAccountGetWebFormSplitTests(AccountTestCase):

def setUp(self):
TestAWeberAccountEntry.setUp(self)
super(TestAccountGetWebFormSplitTests, self).setUp()
self.forms = self.account.get_web_form_split_tests()

def test_should_be_a_list(self):
Expand All @@ -99,7 +99,8 @@ def test_each_should_have_correct_url(self):
for entry in self.forms:
self.assertTrue(re.match(url_regex, entry.url))

class TestAccountFindSubscribers(TestAWeberAccountEntry):

class TestAccountFindSubscribers(AccountTestCase):

def test_should_support_find_method(self):
base_url = '/accounts/1'
Expand All @@ -114,15 +115,17 @@ def test_should_support_find_method(self):
assert subscribers[0].self_link == \
'https://api.aweber.com/1.0/accounts/1/lists/303449/subscribers/1'

class TestSubscriber(TestCase):

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)

class TestGetAndSetData(TestSubscriber):

class TestGetAndSetData(SubscriberTestCase):

def test_get_name(self):
self.assertEqual(self.subscriber.name, 'Joe Jones')
Expand Down Expand Up @@ -183,10 +186,10 @@ def test_should_reset_diff(self):
self.assertEqual(self.subscriber._diff, {})


class TestSavingSubscriberData(TestSubscriber):
class TestSavingSubscriberData(SubscriberTestCase):

def setUp(self):
TestSubscriber.setUp(self)
super(TestSavingSubscriberData, self).setUp()
self.aweber.adapter.requests = []
self.subscriber.name = 'Gary Oldman'
self.subscriber.custom_fields['Color'] = 'Red'
Expand Down Expand Up @@ -216,6 +219,7 @@ def test_should_given_all_custom_fields(self):
self.assertEqual(self.req['data']['custom_fields']['Color'], 'Red')
self.assertEqual(self.req['data']['custom_fields']['Walruses'], '')


class TestSavingInvalidSubscriberData(TestCase):

def setUp(self):
Expand All @@ -231,10 +235,11 @@ def setUp(self):
def test_save_failed(self):
self.assertFalse(self.resp)

class TestDeletingSubscriberData(TestSubscriber):

class TestDeletingSubscriberData(SubscriberTestCase):

def setUp(self):
TestSubscriber.setUp(self)
super(TestDeletingSubscriberData, self).setUp()
self.aweber.adapter.requests = []
self.response = self.subscriber.delete()
self.req = self.aweber.adapter.requests[0]
Expand All @@ -248,6 +253,7 @@ def test_should_have_made_request(self):
def test_should_have_made_delete(self):
self.assertEqual(self.req['method'], 'DELETE')


class TestFailedSubscriberDelete(TestCase):

def setUp(self):
Expand All @@ -262,6 +268,7 @@ def setUp(self):
def test_should_have_failed(self):
self.assertFalse(self.response)


class TestGettingParentEntry(TestCase):

def setUp(self):
Expand All @@ -287,4 +294,3 @@ def test_custom_field_parent_should_be_list(self):
def test_account_parent_should_be_none(self):
entry = self.account.get_parent_entry()
self.assertEqual(entry, None)