def setUp(self): tempCourse = CourseData(title="course1", id=1, designation="cs1") tempCourse.save() CourseSections.objects.create(course=tempCourse, section=201) CourseSections.objects.create(course=tempCourse, section=202) MyUser.objects.create(username="******", position=UserType.INSTRUCTOR) MyUser.objects.create(username="******", position=UserType.TA)
def setUp(self): self.Client = Client() # self.Client.session["position"] = "S" # self.Client.session.save() # creates 3 users (user0, user1, user2) # for i in range(3): self.temp = MyUser(username="******", first_name="john", last_name="deer", position=UserType.SUPERVISOR) self.temp.set_password(raw_password="******") self.temp.save() self.temp1 = MyUser(username="******", first_name="john", last_name="deer", position=UserType.INSTRUCTOR) self.temp1.set_password(raw_password="******") self.temp1.save() self.ta = MyUser(username="******", position=UserType.TA) self.ta.save() self.data = CourseData(title="Class", designation="CS1") self.data.save() self.course = CourseSections(course=self.data, section=901, instructor=self.temp1) self.course.save() self.Lab = LabData(course=self.data, section=902) self.Lab.save()
def setUp(self): self.Client = Client() self.Client.session["position"] = "S" self.Client.session.save() # creates 3 users (user0, user1, user2) # for i in range(3): self.temp = MyUser(username="******", first_name="john", last_name="deer", position="S") self.temp.set_password(raw_password="******") self.temp.save() self.temp1 = MyUser(username="******", first_name="jim", last_name="dean", position="I") self.temp1.set_password(raw_password="******") self.temp1.save() self.temp2 = MyUser(username="******", first_name="jack", last_name="daniels", position="T") self.temp1.set_password(raw_password="******") self.temp1.save() self.data = CourseData(title="Cs") self.course = CourseSections(course=self.data, section=901) self.TA = TASkills(skills="Math")
def setUp(self): self.Client = Client() self.temp1 = MyUser(username="******", first_name="john", last_name="deer", position=UserType.INSTRUCTOR) self.temp1.set_password(raw_password="******") self.temp1.save() self.ta = MyUser(username="******", position=UserType.I) self.ta.save() self.data = CourseData(title="Class", designation="CS1") self.data.save() self.course = CourseSections(course=self.data, section=901, instructor=self.temp1) self.course.save()
def test_makeSureItsWorking(self): course = CourseData(title="course2", designation="CS352") course.save() section = CourseSections(section=201, course=course) section.save() section = CourseSections(section=202, course=course) section.save() course = CourseData(title="course3", designation="CS353") course.save() section = CourseSections(section=201, course=course) section.save() section = CourseSections(section=202, course=course) section.save() temp = list(CourseSections.objects.filter(course__title="course1")) print(len(temp)) temp = list( map(str, CourseSections.objects.filter(course__title="course2"))) print(temp)
def setUp(self): self.Client = Client() self.Client.session["position"] = "S" self.Client.session.save() # creates 3 users (user0, user1, user2) # for i in range(3): self.temp = MyUser(username="******", first_name="john", last_name="deer", position="S") self.temp.set_password(raw_password="******") self.temp.save() self.data = CourseData(title="Cs") self.course = CourseSections(course=self.data, section=901, instructor=self.temp1) self.Lab = LabData(course=self.course, section=902)
class testAssignTA(TestCase): def setUp(self): self.Client = Client() # self.Client.session["position"] = "S" # self.Client.session.save() # creates 3 users (user0, user1, user2) # for i in range(3): self.temp = MyUser(username="******", first_name="john", last_name="deer", position=UserType.SUPERVISOR) self.temp.set_password(raw_password="******") self.temp.save() self.temp1 = MyUser(username="******", first_name="john", last_name="deer", position=UserType.INSTRUCTOR) self.temp1.set_password(raw_password="******") self.temp1.save() self.ta = MyUser(username="******", position=UserType.TA) self.ta.save() self.data = CourseData(title="Class", designation="CS1") self.data.save() self.course = CourseSections(course=self.data, section=901, instructor=self.temp1) self.course.save() self.Lab = LabData(course=self.data, section=902) self.Lab.save() def test_01(self): response1 = self.client.post(reverse('login'), { 'username': '******', 'password': '******' }, follow=True) self.assertEqual( reverse('home'), response1.request['PATH_INFO'], "Valid Information does not take to the homepage page") response = self.Client.post( "/create_account/", { "username": "******", "password": "******", "first_name": "brett", "last_name": "frank", "addressln1": "3423 N Maryland", "addressln2": "Milwaukee wi", "title": "TA", "email": "*****@*****.**", "number": "123456789" }) self.assertEqual(response.context.get("message"), "successfully created account", msg="No message for confirmed account creation") self.assertEqual(reverse('home'), response1.request["PATH_INFO"]) # assign the user created to the course declared in setUp response2 = self.Client.post("/Create_Lab/", {"Lab": 1}, follow=True) self.assertEqual(reverse('home'), response2.request['PATH_INFO']) def test_02(self): response1 = self.client.post(reverse('login'), { 'username': '******', 'password': '******' }, follow=True) self.assertEqual(reverse('home'), response1.request["PATH_INFO"], "Valid Information will take to the homepage page") response = self.Client.post( "/create_account/", { "username": "******", "password": "******", "first_name": "brett", "last_name": "frank", "addressln1": "3423 N Maryland", "addressln2": "Milwaukee WI", "title": "TA", "email": "*****@*****.**", "number": "123456789" }) self.assertEqual(response.context["message"], "successfully created account", msg="confirmed account creation") self.assertEqual(reverse('home'), response.request["PATH_INFO"]) # assign the user created to the course declared in setUp response2 = self.Client.post("/Create_Lab/", {"Lab": 2}) self.assertEqual("/Create_Lab/", response2.request["PATH_INFO"], "Lab does not exist")
def setUp(self): self.tempCourse = CourseData(title="course1", id=1, designation="cs1") self.tempCourse.save()
class CreateLabTest(TestCase): def setUp(self): self.tempCourse = CourseData(title="course1", id=1, designation="cs1") self.tempCourse.save() def test_goodData(self): check = make_lab({"designation": "cs1", "section": 801}) self.assertTrue( check, msg="Error: creating a lab for a course that exists fails") query = list(LabData.objects.filter(course__title="course1")) self.assertEqual(len(query), 1, msg="Error: a single lab is not created for a course") self.assertEqual( query[0].section, 801, msg="Error: correct section is not created for the lab") def test_badData(self): check = make_lab({"designation": 1, "section": 801}) self.assertFalse(check, msg="Error: bad course id does not fail") query = list(LabData.objects.filter(course__title="course1")) self.assertEqual(len(query), 0, msg="Error: a lab is created when courseId is bad") check = make_lab({"designation": "cs1", "section": "801"}) self.assertFalse(check, msg="Error: bad section id does not fail") query = list(LabData.objects.filter(course__title="course1")) self.assertEqual(len(query), 0, msg="Error: a lab is created when section id is bad") def test_labExists(self): make_lab({"designation": "cs1", "section": 801}) check = make_lab({"designation": "cs1", "section": 801}) self.assertFalse( check, msg="Error: making a lab that already exists does not fail") query = list(LabData.objects.filter(course__title="course1")) self.assertEqual( len(query), 1, msg= "Error: there is not exactly 1 lab section when identical data is passed" ) def test_courseDoesNotExist(self): check = make_lab({"designation": "cs2", "section": 801}) self.assertFalse( check, msg="Error: making lab does not fail when course does not exist") query = list(LabData.objects.all()) self.assertEqual( len(query), 0, msg="Error: a lab is created when coures does not exist") def test_missingData(self): check = make_lab({"section": 801}) self.assertFalse( check, msg="Error: making lab does not fail when courseId is not given") query = list(LabData.objects.all()) self.assertEqual( len(query), 0, msg="Error: a lab is created when coures is not provided") check = make_lab({"designation": "cs1"}) self.assertFalse( check, msg="Error: making lab does not fail when section is not given") query = list(LabData.objects.all()) self.assertEqual( len(query), 0, msg="Error: a lab is created when section is not given") def test_twoLabsOneCourse(self): make_lab({"designation": "cs1", "section": 801}) check = make_lab({"designation": "cs1", "section": 802}) self.assertTrue( check, msg= "Error: making lab fails when labs for the same course have different sections" ) query = list(LabData.objects.all()) self.assertEqual( len(query), 2, msg="Error: lab is not created when section is unique.")