Ejemplo n.º 1
0
 def setUp(self):
     self.user_with_instance = create_user_and_profile(
         'instance.user', '*****@*****.**')
     self.existing_instance_config = BetaTestApplication.objects.create(
         user=self.user_with_instance,
         subdomain='somesubdomain',
         instance_name="User's Instance",
         public_contact_email='*****@*****.**',
         privacy_policy_url='http://www.some/url')
Ejemplo n.º 2
0
 def setUp(self):
     self.user1 = create_user_and_profile("instance.user1",
                                          "*****@*****.**")
     self.user2 = create_user_and_profile("instance.user2",
                                          "*****@*****.**")
     self.app_with_external_domain = BetaTestApplication.objects.create(
         user=self.user1,
         subdomain="somesubdomain",
         external_domain="externaldomain.com",
         dns_configuration_state=DNSConfigState.pending,
         instance_name="User's Instance",
         public_contact_email="*****@*****.**",
         privacy_policy_url="http://www.some/url")
     self.app_without_external_domain = BetaTestApplication.objects.create(
         user=self.user2,
         subdomain="somesubdomain2",
         instance_name="User's Instance",
         public_contact_email="*****@*****.**",
         privacy_policy_url="http://www.some/url")
Ejemplo n.º 3
0
 def setUp(self):
     self.user_with_instance = create_user_and_profile(
         "instance.user", "*****@*****.**")
     self.instance_config = BetaTestApplication.objects.create(
         user=self.user_with_instance,
         subdomain="somesubdomain",
         instance_name="User's Instance",
         public_contact_email="*****@*****.**",
         privacy_policy_url="http://www.some/url")
     EmailAddress.objects.create_confirmed(
         email=self.instance_config.public_contact_email,
         user=self.user_with_instance,
     )
     self.instance_config_defaults = dict(
         project_description="",
         privacy_policy_url="",
         use_advanced_theme=False,
         draft_theme_config=None,
     )
     self.user_without_instance = create_user_and_profile(
         "noinstance.user", "*****@*****.**")
Ejemplo n.º 4
0
    def setUp(self):
        self.maxDiff = None

        self.user_with_instance = create_user_and_profile(
            "instance.user", "*****@*****.**")
        self.instance_config = BetaTestApplication.objects.create(
            user=self.user_with_instance,
            subdomain="somesubdomain",
            instance_name="User's Instance",
            public_contact_email="*****@*****.**",
            privacy_policy_url="http://www.some/url",
        )
        self.client.force_login(self.user_with_instance)
Ejemplo n.º 5
0
 def setUp(self):
     """
     Setup the user with a BetaTestApplication
     """
     super().setUp()
     self.user_with_app = create_user_and_profile('instance.user', '*****@*****.**')
     self.application = BetaTestApplication.objects.create(
         user=self.user_with_app,
         subdomain="somesubdomain",
         instance_name="User's Instance",
         public_contact_email="*****@*****.**",
         privacy_policy_url="http://www.some/url"
     )
     EmailAddress.objects.create_confirmed(
         email=self.application.public_contact_email,
         user=self.user_with_app,
     )
Ejemplo n.º 6
0
 def setUp(self):
     self.user = create_user_and_profile("test.user",
                                         "*****@*****.**")
     self.reference_time = timezone.now() - timezone.timedelta(hours=1)
     self.user.profile.accepted_privacy_policy = self.reference_time
     self.user.profile.save()
     self.user_data = {
         "username": "******",
         "password": "******",
         "email": "*****@*****.**",
     }
     self.profile_data = {
         "full_name": "Another User",
         "accepted_privacy_policy": self.reference_time,
         "accept_paid_support": True,
         "subscribe_to_updates": True
     }
     self.account_data = {**self.user_data, **self.profile_data}
Ejemplo n.º 7
0
    def _check(self,
               mock_mailchimp_update_members,
               mock_mailchimp_list_members,
               mock_mailchimp_auth,
               emails_local,
               emails_mailchimp,
               expected_batched_updates,
               mailchimp_enabled=True,
               batch_size=10):
        """
        Mocks the MailChimp API and then runs a specific test scenario.
        """
        emails_local_subscribed = []
        for email in emails_local:
            profile = create_user_and_profile(email, email).profile
            if 'unsubscribed' not in email:
                emails_local_subscribed.append(email)
                profile.subscribe_to_updates = True
                profile.save()

        mock_mailchimp_list_members.return_value = {
            'members': [{
                'email_address': email
            } for email in emails_mailchimp],
        }

        with self.settings(MAILCHIMP_BATCH_SIZE=batch_size,
                           MAILCHIMP_ENABLED=mailchimp_enabled):
            tasks.add_trial_users_to_mailchimp_list.call_local()

        self.assertEqual(mock_mailchimp_update_members.call_count,
                         len(expected_batched_updates))
        for batch in expected_batched_updates:
            mock_mailchimp_update_members.assert_any_call(
                settings.MAILCHIMP_LIST_ID_FOR_TRIAL_USERS,
                data={
                    'members': [{
                        'email_address': email,
                        'status': action,
                    } for email, action in batch],
                    'update_existing':
                    True,
                })