Giter Site home page Giter Site logo

mailchimpy's Introduction

mailchimpy

A python 3 client for the MailChimp API v3, while we're waiting for the official MailChimp python wrapper to be released.

Installation

pip install git+git://github.com/discopatrick/mailchimpy

Example usage

from mailchimpy import MailChimpClient

mc = MailChimpClient(YOUR_API_KEY)

(exists, subscribed) = mc.check_subscription_status('[email protected]', YOUR_LIST_ID)

if not subscribed:
    mc.subscribe_email_to_list('[email protected]', YOUR_LIST_ID):

Tests

  • Clone this repo.
  • pip install -r requirements.txt
  • Create a file inside tests/ called config.py containing these values (see config-example.py for an example):
    • MAILCHIMP_API_KEY (the API key of a MailChimp account you have created for test purposes - do not use a real account!)
  • python3 -m unittest tests.test_mailchimpclient

In order to minimise the number of requests made to the MailChimp API, and to keep the tests focussed on testing our code rather than the API itself, mailchimpy uses betamax to record http interactions and then play them back.

On the first test run, all tests will need to make real calls to the API over the internet. Subsequent test runs will use the betamax recordings, and will be much quicker.

There are two test modules:

test_mailchimpclient

These tests are for our client. Some of the tests rely on an email address already being subscribed to the list. Because of this, some tests need to make an extra API call to create this subscription before performing the test itself. Wherever this occurs, the 'arrange' step of the test will make API calls via Python's requests module, while the 'act' step of the test will use our mailchimpy client. This is to ensure (as much as is possible) that we are only testing one thing at a time.

From the project root, run:

python3 -m unittest tests.test_mailchimpclient

test_mailchimpapi

These tests are for the MailChimp API itself. Strictly, we shouldn't be testing the API directly, as it's not our code. However, these tests help us understand how the API works, and will warn us of any changes to the API that may be introduced.

From the project root, run:

python3 -m unittest tests.test_mailchimpapi

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.