[BB-2236] Create a periodic task that adds opted-in trial users to the MailChimp list
This PR fixes the Jira issue BB-2236.
Testing instructions:
-
clone the OpenCraft Instance Manager (Ocim) git repository:
git clone https://github.com/open-craft/opencraft ocim cd ocim
-
switch to this PRs git branch:
git checkout petarmaric/bb-2236-add-trial-users-to-mailchimp-list
-
clone the OpenCraft's Ansible playbooks git repository, used to build the Vagrant-powered development environment:
git clone https://github.com/open-craft/ansible-playbooks deploy
-
start and provision the Ocim development environment virtual machine (VM):
vagrant up
-
run only the unit tests that are focused on this PR (fast):
vagrant ssh --command "bash -ilc 'make test.one userprofile.tests.test_tasks.AddTrialUsersToMailchimpListTestCase'"
-
run the entire Ocim test suite (pylint, pyflakes, pep8, unit tests, ...) as a sanity-check (slow):
vagrant ssh --command "bash -ilc 'make test'"
-
run the Minimal Reproducible Example (MRE):
-
edit the
MAILCHIMP_API_KEY
andMAILCHIMP_LIST_ID_FOR_TRIAL_USERS
settings in.env
-
save the following Python script to
mre.py
:import secrets from instance.tests.base import create_user_and_profile from userprofile import tasks email = "bb-2236+%s@opencraft.com" % secrets.token_hex(4) profile = create_user_and_profile(email, email).profile profile.subscribe_to_updates = True profile.save() tasks.add_trial_users_to_mailchimp_list.call_local() print("\nCreated a 'fake' subscriber %s - see him on https://us7.admin.mailchimp.com/lists/members/\n" % email)
-
run the MRE:
vagrant ssh --command "bash -ilc 'make migrate; honcho run python manage.py shell -c \"import mre\"'"
-
review the MailChimp list for opted-in trial users, and check if the newly created 'fake' subscriber has been added to it
-
-
finally, stop and delete the Ocim development environment VM:
vagrant destroy