'Test for user logged in and allowed to enroll in invitation only course.'

def test_invitation_only_but_allowed(self):

    user = UserFactory.create(username='allowed_student', password='test', email='allowed_student@test.com')
    CourseEnrollmentAllowedFactory(email=user.email, course_id=self.course.id)
    self.client.login(username=user.username, password='test')
    url = reverse('about_course', args=[self.course.id.to_deprecated_string()])
    resp = self.client.get(url)
    self.assertEqual(resp.status_code, 200)
    self.assertIn(u'Enroll    in    {}'.format(self.course.id.course), resp.content.decode('utf-8'))
    self.assertIn(REG_STR, resp.content)
