def test_accessData(self): userdata = USER.objects.get(username="******") user = User.User(userdata.permission, userdata.username, userdata.password, userdata.id, userdata.email, userdata.firstName, userdata.lastName, userdata.contactPhone, userdata.officePhone, userdata.extension) userdata2 = USER.objects.get(username="******") user2 = User.User(userdata2.permission, userdata2.username, userdata2.password, userdata2.id, userdata2.email, userdata2.firstName, userdata2.lastName, userdata2.contactPhone, userdata2.officePhone, userdata2.extension) userdata3 = USER.objects.get(username="******") user3 = User.User(userdata3.permission, userdata3.username, userdata3.password, userdata3.id, userdata3.email, userdata3.firstName, userdata3.lastName, userdata3.contactPhone, userdata3.officePhone, userdata3.extension) userdata4 = USER.objects.get(username="******") user4 = User.User(userdata4.permission, userdata4.username, userdata4.password, userdata4.id, userdata4.email, userdata4.firstName, userdata4.lastName, userdata4.contactPhone, userdata4.officePhone, userdata4.extension) courseData = COURSE.objects.get(courseNumber=500) course = Course.Course(courseData.id, courseData.name, courseData.courseNumber, courseData.classNumber, courseData.time, courseData.location) print(user.permission[1]) self.assertTrue(user.permission[1] == '1') self.assertTrue(user2.permission[1] == '2') self.assertTrue(user3.permission[1] != '1') self.assertTrue(user3.permission[1] != '2') self.assertTrue(user4.permission[1] != '1', "Not Authorized To Use This Command") self.assertTrue(user4.permission[1] != '2', "Not Authorized To Use This Command") self.user = user self.assertEqual( Terminal.accessData(self), str(user.permission) + " " + user.username + " " + user.password + " " + str(user.databaseID) + " " + user.email + " " + user.firstName + " " + user.lastName + " " + user.contactPhone + " " + user.officePhone + " " + user.extension + "\n " + str(user2.permission) + " " + user2.username + " " + user2.password + " " + str(user2.databaseID) + " " + user2.email + " " + user2.firstName + " " + user2.lastName + " " + user2.contactPhone + " " + user2.officePhone + " " + user2.extension + "\n " + str(user3.permission) + " " + user3.username + " " + user3.password + " " + str(user3.databaseID) + " " + user3.email + " " + user3.firstName + " " + user3.lastName + " " + user3.contactPhone + " " + user3.officePhone + " " + user3.extension + "\n " + str(user4.permission) + " " + user4.username + " " + user4.password + " " + str(user4.databaseID) + " " + user4.email + " " + user4.firstName + " " + user4.lastName + " " + user4.contactPhone + " " + user4.officePhone + " " + user4.extension + "\n " + str(course.databaseID) + " " + course.name + " " + str(course.courseNumber) + " " + str(course.classNumber) + " " + str(course.labList) + " " + course.time + " " + course.location)
def test_createAccount(self): userdata = USER.objects.get(username="******") user = User.User(userdata.permission, userdata.username, userdata.password, userdata.id, userdata.email, userdata.firstName, userdata.lastName, userdata.contactPhone, userdata.officePhone, userdata.extension) userdata2 = USER.objects.get(username="******") user2 = User.User(userdata2.permission, userdata2.username, userdata2.password, userdata2.id, userdata2.email, userdata2.firstName, userdata2.lastName, userdata2.contactPhone, userdata2.officePhone, userdata2.extension) userdata3 = USER.objects.get(username="******") user3 = User.User(userdata3.permission, userdata3.username, userdata3.password, userdata3.id, userdata3.email, userdata3.firstName, userdata3.lastName, userdata3.contactPhone, userdata3.officePhone, userdata3.extension) self.user = user2 self.assertTrue(user.permission[1] == '1') self.assertTrue(user2.permission[1] != '1') self.assertTrue(user2.permission[1] == '2', "Not Authorized To Use This Command") self.assertTrue(user3.permission[1] != '1') self.assertEquals( Terminal.createAccount(self, '2', 'jjj', '123', '*****@*****.**', 'John', 'Aponte', '2011111111', '2012222222', '47'), "New user created") self.assertEqual( Terminal.createAccount(self, '3', 'jjj', 'aaa', '*****@*****.**', 'John', 'Aponte', '2011111111', '2012222222', '47'), "Account Already Exists") self.assertEqual( Terminal.createAccount(self, '4', 'bbb', 'ccc', '*****@*****.**', 'John', 'Aponte', '2033333333', '2044444444', '48'), "New user created") self.assertEqual( Terminal.createAccount(self, '2', 'bbb', 'ccc', '*****@*****.**', 'Hn', 'Te', '2055555555', '2066666666', '49'), "Username Already Exist") self.assertEqual( Terminal.createAccount(self, '1', 'eee', 'zzz', '*****@*****.**', 'Jo', 'Ap', '2066666666', '207777777', '48'), "Email Already In Use") self.assertEqual( Terminal.createAccount(self, '3', 'hhh', 'yyy', '*****@*****.**', 'Doom', 'Kek', '2066666666', '2044444444', '48'), "Phone Number Already in Use") self.assertEqual( Terminal.createAccount(self, '0', 'hhh', 'yyy', '*****@*****.**', 'Doom', 'Kek', '2066666666', '2044444444', '48'), "Invalid Permission") self.assertEqual( Terminal.createAccount(self, '5', 'hhh', 'yyy', '*****@*****.**', 'Doom', 'Kek', '2066666666', '2044444444', '48'), "Invalid Permission") self.assertEqual( Terminal.createAccount(self, '3', '', 'yyy', '*****@*****.**', 'Doom', 'Kek', '2066666666', '2044444444', '48'), "Invalid Username") self.assertEqual( Terminal.createAccount(self, '3', 'hhh', '', '*****@*****.**', 'Doom', 'Kek', '2066666666', '2044444444', '48'), "Invalid Password") self.assertEqual( Terminal.createAccount(self, '3', 'hhh', 'yyy', 'dfsiahfilnwefr', 'Doom', 'Kek', '2066666666', '2044444444', '48'), "Invalid Email") self.assertEqual( Terminal.createAccount(self, '3', 'hhh', 'yyy', '', 'Doom', 'Kek', '2066666666', '2044444444', '48'), "Invalid Email") self.assertEqual( Terminal.createAccount(self, '3', 'hhh', 'yyy', '*****@*****.**', '', 'Kek', '2066666666', '2044444444', '48'), "Must Enter Valid Name") self.assertEqual( Terminal.createAccount(self, '3', 'hhh', 'yyy', '*****@*****.**', 'Doom', '', '2066666666', '2044444444', '48'), "Must Enter Valid Name") self.assertEqual( Terminal.createAccount(self, '3', 'hhh', 'yyy', '*****@*****.**', 'Doom', 'Kek', '4535387478347874878247', '2044444444', '48'), "Invalid Phone Number") self.assertEqual( Terminal.createAccount(self, '3', 'hhh', 'yyy', '*****@*****.**', 'Doom', 'Kek', '12334', '2044444444', '48'), "Invalid Phone Number") # Instead of having a general error, have the errors listed by the order of their fault. ex: the username in the # first error so it would spit out "Invalid username", then once its fixed, it would spit out "Invalid Email" self.assertEqual( Terminal.createAccount(self, '3', ' ', 'yyy', '*****@*****.**', 'Do2om', '11', '2063242342346666666', '204444444423244', '4238'), "Multiple Invalid Credentials")
def test_createCourse(self): userdata = USER.objects.get(username="******") user = User.User(userdata.permission, userdata.username, userdata.password, userdata.id, userdata.email, userdata.firstName, userdata.lastName, userdata.contactPhone, userdata.officePhone, userdata.extension) userdata2 = USER.objects.get(username="******") user2 = User.User(userdata2.permission, userdata2.username, userdata2.password, userdata2.id, userdata2.email, userdata2.firstName, userdata2.lastName, userdata2.contactPhone, userdata2.officePhone, userdata2.extension) userdata3 = USER.objects.get(username="******") user3 = User.User(userdata3.permission, userdata3.username, userdata3.password, userdata3.id, userdata3.email, userdata3.firstName, userdata3.lastName, userdata3.contactPhone, userdata3.officePhone, userdata3.extension) self.assertTrue(user.permission[1] == '1') self.assertTrue(user2.permission[1] == '2') self.assertTrue( (user3.permission[1] != '1' and user2.permission[1] == '2'), "Not Authorized To Use This Command") courseData = COURSE.objects.get(courseNumber=500) course = Course.Course(courseData.id, courseData.name, courseData.courseNumber, courseData.classNumber, courseData.time, courseData.location) self.user = user self.assertEqual( Terminal.createCourse(self, course.name, course.courseNumber, course.classNumber, course.time, course.location), "Course Has Been Created") self.assertEqual( Terminal.createCourse(self, course.name, course.courseNumber, course.classNumber, course.time, course.location), "Course Already Exists") self.assertEqual( Terminal.createCourse(self, 'sdfs)gfsfw:::::', course.courseNumber, course.classNumber, course.time, course.location), "Invalid name") self.assertEqual( Terminal.createCourse(self, course.name, 'sdkjfbdf', course.classNumber, course.time, course.location), "Invalid Course Number") self.assertEqual( Terminal.createCourse(self, course.name, course.courseNumber, '34kb23id', course.time, course.location), "Invalid Class Number") self.assertEqual( Terminal.createCourse(self, course.name, course.courseNumber, course.classNumber, 'sdffw', course.location), "Invalid Time") self.assertEqual( Terminal.createCourse(self, course.name, course.courseNumber, course.classNumber, course.time, 'eq2"kbt'), "Invalid Location") #Have in order error reports self.assertEqual( Terminal.createCourse(self, 'eiufb23]]u', 'sdfsdf', 'wefwvfwe', 'wergewrg', 'wefwefwef"'), "Multiple Invalid Info")