Пример #1
0
 def test_mes_create(self):
     """
     Test SettableEnrollmentState creation of user.
     """
     mes = SettableEnrollmentState(user=True,
                                   enrollment=True,
                                   allowed=False,
                                   auto_enroll=False)
     # enrollment objects
     eobjs = mes.create_user(self.course_key)
     ees = EmailEnrollmentState(self.course_key, eobjs.email)
     self.assertEqual(mes, ees)
Пример #2
0
    def _run_state_change_test(self, before_ideal, after_ideal, action):
        """
        Runs a state change test.

        `before_ideal` and `after_ideal` are SettableEnrollmentState's
        `action` is a function which will be run in the middle.
            `action` should transition the world from before_ideal to after_ideal
            `action` will be supplied the following arguments (None-able arguments)
                `email` is an email string
        """
        # initialize & check before
        print "checking initialization..."
        eobjs = before_ideal.create_user(self.course_key)
        before = EmailEnrollmentState(self.course_key, eobjs.email)
        self.assertEqual(before, before_ideal)

        # do action
        print "running action..."
        action(eobjs.email)

        # check after
        print "checking effects..."
        after = EmailEnrollmentState(self.course_key, eobjs.email)
        self.assertEqual(after, after_ideal)