def METHOD_NAME(self):
    """
    Tests that the admin account is notified when a user is in the 'pending' state.
    """
    def check_admin_message_state(state, expect_sent_to_admin, expect_sent_to_user):
        """ Changes user state and verifies e-mail sent to admin address only when pending. """
        mail.outbox = []
        self._change_state(state)
        # If a message is sent to the user about course creator status change, it will be the first
        # message sent. Admin message will follow.
        base_num_emails = 1 if expect_sent_to_user else 0
        if expect_sent_to_admin:
            context = {'user_name': 'test_user', 'user_email': 'test_user+courses@edx.org'}
            self.assertEqual(base_num_emails + 1, len(mail.outbox), 'Expected admin message to be sent')
            sent_mail = mail.outbox[base_num_emails]
            self.assertEqual(
                mock_render_to_string('emails/course_creator_admin_subject.txt', context),
                sent_mail.subject
            )
            self.assertEqual(
                mock_render_to_string('emails/course_creator_admin_user_pending.txt', context),
                sent_mail.body
            )
            self.assertEqual(self.studio_request_email, sent_mail.from_email)
            self.assertEqual([self.studio_request_email], sent_mail.to)
        else:
            self.assertEqual(base_num_emails, len(mail.outbox))
    with mock.patch.dict('django.conf.settings.FEATURES', self.enable_creator_group_patch):
        # E-mail message should be sent to admin only when new state is PENDING, regardless of what
        # previous state was (unless previous state was already PENDING).
        # E-mail message sent to user only on transition into and out of GRANTED state.
        check_admin_message_state(CourseCreator.UNREQUESTED, expect_sent_to_admin=False, expect_sent_to_user=False)
        check_admin_message_state(CourseCreator.PENDING, expect_sent_to_admin=True, expect_sent_to_user=False)
        check_admin_message_state(CourseCreator.GRANTED, expect_sent_to_admin=False, expect_sent_to_user=True)
        check_admin_message_state(CourseCreator.DENIED, expect_sent_to_admin=False, expect_sent_to_user=True)
        check_admin_message_state(CourseCreator.GRANTED, expect_sent_to_admin=False, expect_sent_to_user=True)
        check_admin_message_state(CourseCreator.PENDING, expect_sent_to_admin=True, expect_sent_to_user=True)
        check_admin_message_state(CourseCreator.PENDING, expect_sent_to_admin=False, expect_sent_to_user=False)
        check_admin_message_state(CourseCreator.DENIED, expect_sent_to_admin=False, expect_sent_to_user=True)