Skip to content

[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:

  1. clone the OpenCraft Instance Manager (Ocim) git repository:

    git clone https://github.com/open-craft/opencraft ocim
    cd ocim
  2. switch to this PRs git branch:

    git checkout petarmaric/bb-2236-add-trial-users-to-mailchimp-list
  3. 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
  4. start and provision the Ocim development environment virtual machine (VM):

    vagrant up
  5. 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'"
  6. run the entire Ocim test suite (pylint, pyflakes, pep8, unit tests, ...) as a sanity-check (slow):

    vagrant ssh --command "bash -ilc 'make test'"
  7. run the Minimal Reproducible Example (MRE):

    1. edit the MAILCHIMP_API_KEY and MAILCHIMP_LIST_ID_FOR_TRIAL_USERS settings in .env

    2. 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)
    3. run the MRE:

      vagrant ssh --command "bash -ilc 'make migrate; honcho run python manage.py shell -c \"import mre\"'"
    4. review the MailChimp list for opted-in trial users, and check if the newly created 'fake' subscriber has been added to it

  8. finally, stop and delete the Ocim development environment VM:

    vagrant destroy

Merge request reports