Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
self.add_permission(user, "add_page")
if not can_add_page and random.choice([True, False]):
self.add_permission(user, "change_page")
# Trigger the creation of a snapshot for the course
url = "/en/admin/courses/course/{:d}/snapshot/".format(course.id)
with mock.patch("time.time", mock.MagicMock(return_value=1541946888)):
response = self.client.post(url, follow=True)
self.assertEqual(response.status_code, 403)
self.assertEqual(
response.content,
b"You don't have sufficient permissions to snapshot this page.",
)
# No additional courses should have been created
self.assertEqual(Course.objects.count(), 2)
def test_models_person_get_courses_several_languages(self):
"""
The courses should not be duplicated if they exist in several languages.
"""
person = PersonFactory(should_publish=True)
CourseFactory(
page_title={"en": "my title", "fr": "mon titre"},
fill_team=[person],
should_publish=True,
)
self.assertEqual(Course.objects.count(), 2)
self.assertEqual(person.get_courses().count(), 1)