from mailchimp_manager import MailChimpManager
import unittest

TEST_EMAIL = u'john.doe@gmail.com'

class TestMailChimpListManager(unittest.TestCase):
    def test_Subscribe_TestEmailInSubscribedList_True(self):
        listMgr = MailChimpManager.ListManager()
        listMgr.subscribe(TEST_EMAIL)
        emails = listMgr.listMembers()
        self.assertIn(TEST_EMAIL, emails)

    def test_Unsubscribe_TestEmailInSubscribeList_False(self):
        listMgr = MailChimpManager.ListManager()
        listMgr.unsubscribe(TEST_EMAIL)
        emails = listMgr.listMembers()
        self.assertNotIn(TEST_EMAIL, emails)

    def test_Unsubscribe_TestEmailInUnsubscribeList_True(self):
        listMgr = MailChimpManager.ListManager()
        listMgr.unsubscribe(TEST_EMAIL)
        emails = listMgr.listMembers(MailChimpManager.ListManager.MEMBER_STATUS.UNSUBSCRIBED)
        self.assertIn(TEST_EMAIL, emails)

if __name__ == '__main__':
    suite = unittest.TestLoader().loadTestsFromTestCase(TestMailChimpListManager)
    unittest.TextTestRunner(verbosity=2).run(suite)

try:
    from mailchimp_manager import MailChimpManager
except:
    # Local module testing - assuming mailchimp_manager folder put in grandparent folder
    import sys, os.path
    # Hack for import module in grandparent folder
    sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir, os.path.pardir)))
    from mailchimp_manager import MailChimpManager
import unittest

TEST_EMAIL = u'john.doe@gmail.com'

class TestMailChimpListManager(unittest.TestCase):
    def test_Subscribe_TestEmailInSubscribedList_True(self):
        listMgr = MailChimpManager.ListManager()
        listMgr.subscribe(TEST_EMAIL)
        emails = listMgr.listMembers()
        self.assertIn(TEST_EMAIL, emails)

    def test_Unsubscribe_TestEmailInSubscribeList_False(self):
        listMgr = MailChimpManager.ListManager()
        listMgr.unsubscribe(TEST_EMAIL)
        emails = listMgr.listMembers()
        self.assertNotIn(TEST_EMAIL, emails)

    def test_Unsubscribe_TestEmailInUnsubscribeList_True(self):
        listMgr = MailChimpManager.ListManager()
        listMgr.unsubscribe(TEST_EMAIL)
        emails = listMgr.listMembers(MailChimpManager.ListManager.MEMBER_STATUS.UNSUBSCRIBED)
        self.assertIn(TEST_EMAIL, emails)

if __name__ == '__main__':
    suite = unittest.TestLoader().loadTestsFromTestCase(TestMailChimpListManager)
    unittest.TextTestRunner(verbosity=2).run(suite)

Update test script for local testing
Update test script for local testing

+ try:
- from mailchimp_manager import MailChimpManager
+     from mailchimp_manager import MailChimpManager
+ except:
+     # Local module testing - assuming mailchimp_manager folder put in grandparent folder
+     import sys, os.path
+     # Hack for import module in grandparent folder
+     sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir, os.path.pardir)))
+     from mailchimp_manager import MailChimpManager
  import unittest
  
  TEST_EMAIL = u'john.doe@gmail.com'
  
  class TestMailChimpListManager(unittest.TestCase):
      def test_Subscribe_TestEmailInSubscribedList_True(self):
          listMgr = MailChimpManager.ListManager()
          listMgr.subscribe(TEST_EMAIL)
          emails = listMgr.listMembers()
          self.assertIn(TEST_EMAIL, emails)
  
      def test_Unsubscribe_TestEmailInSubscribeList_False(self):
          listMgr = MailChimpManager.ListManager()
          listMgr.unsubscribe(TEST_EMAIL)
          emails = listMgr.listMembers()
          self.assertNotIn(TEST_EMAIL, emails)
  
      def test_Unsubscribe_TestEmailInUnsubscribeList_True(self):
          listMgr = MailChimpManager.ListManager()
          listMgr.unsubscribe(TEST_EMAIL)
          emails = listMgr.listMembers(MailChimpManager.ListManager.MEMBER_STATUS.UNSUBSCRIBED)
          self.assertIn(TEST_EMAIL, emails)
  
  if __name__ == '__main__':
      suite = unittest.TestLoader().loadTestsFromTestCase(TestMailChimpListManager)
      unittest.TextTestRunner(verbosity=2).run(suite)
  
Update test script for local testing
## Code Before:
from mailchimp_manager import MailChimpManager
import unittest

TEST_EMAIL = u'john.doe@gmail.com'

class TestMailChimpListManager(unittest.TestCase):
    def test_Subscribe_TestEmailInSubscribedList_True(self):
        listMgr = MailChimpManager.ListManager()
        listMgr.subscribe(TEST_EMAIL)
        emails = listMgr.listMembers()
        self.assertIn(TEST_EMAIL, emails)

    def test_Unsubscribe_TestEmailInSubscribeList_False(self):
        listMgr = MailChimpManager.ListManager()
        listMgr.unsubscribe(TEST_EMAIL)
        emails = listMgr.listMembers()
        self.assertNotIn(TEST_EMAIL, emails)

    def test_Unsubscribe_TestEmailInUnsubscribeList_True(self):
        listMgr = MailChimpManager.ListManager()
        listMgr.unsubscribe(TEST_EMAIL)
        emails = listMgr.listMembers(MailChimpManager.ListManager.MEMBER_STATUS.UNSUBSCRIBED)
        self.assertIn(TEST_EMAIL, emails)

if __name__ == '__main__':
    suite = unittest.TestLoader().loadTestsFromTestCase(TestMailChimpListManager)
    unittest.TextTestRunner(verbosity=2).run(suite)

## Instruction:
Update test script for local testing
## Code After:
try:
    from mailchimp_manager import MailChimpManager
except:
    # Local module testing - assuming mailchimp_manager folder put in grandparent folder
    import sys, os.path
    # Hack for import module in grandparent folder
    sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir, os.path.pardir)))
    from mailchimp_manager import MailChimpManager
import unittest

TEST_EMAIL = u'john.doe@gmail.com'

class TestMailChimpListManager(unittest.TestCase):
    def test_Subscribe_TestEmailInSubscribedList_True(self):
        listMgr = MailChimpManager.ListManager()
        listMgr.subscribe(TEST_EMAIL)
        emails = listMgr.listMembers()
        self.assertIn(TEST_EMAIL, emails)

    def test_Unsubscribe_TestEmailInSubscribeList_False(self):
        listMgr = MailChimpManager.ListManager()
        listMgr.unsubscribe(TEST_EMAIL)
        emails = listMgr.listMembers()
        self.assertNotIn(TEST_EMAIL, emails)

    def test_Unsubscribe_TestEmailInUnsubscribeList_True(self):
        listMgr = MailChimpManager.ListManager()
        listMgr.unsubscribe(TEST_EMAIL)
        emails = listMgr.listMembers(MailChimpManager.ListManager.MEMBER_STATUS.UNSUBSCRIBED)
        self.assertIn(TEST_EMAIL, emails)

if __name__ == '__main__':
    suite = unittest.TestLoader().loadTestsFromTestCase(TestMailChimpListManager)
    unittest.TextTestRunner(verbosity=2).run(suite)
