'Make sure that capped enrollments work even with
paywalled courses'

def test_enrollment_cap(self):

    course = CourseFactory.create(metadata={'max_student_enrollments_allowed': 1, 'display_coursenumber': 'buyme'})
    self._set_ecomm(course)
    self.setup_user()
    url = reverse('about_course', args=[course.id.to_deprecated_string()])
    resp = self.client.get(url)
    self.assertEqual(resp.status_code, 200)
    self.assertIn('Add    buyme    to    Cart    <span>($10    USD)</span>', resp.content)
    CourseEnrollment.enroll(self.user, course.id)
    email = 'foo_second@test.com'
    password = 'bar'
    username = 'test_second'
    self.create_account(username, email, password)
    self.activate_user(email)
    self.login(email, password)
    resp = self.client.get(url)
    self.assertEqual(resp.status_code, 200)
    self.assertIn('Course    is    full', resp.content)
    self.assertNotIn('Add    buyme    to    Cart    ($10)', resp.content)
