def get(self, request): terminalInstance = Terminal() id = request.session['userid'] user = USER.objects.get(id=id) terminalInstance.login(user.username, user.password) allUsers, bool = terminalInstance.viewContactInfo() if (bool == False): render(request, 'shell/error.html') return render(request, 'shell/viewContactInfo.html', {"allUsers": allUsers})
def test_viewContactInfo(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) self.user = user self.assertEqual( Terminal.viewContactInfo(self), str(user.permission) + " " + user.username + " " + user.password + " " + str(user.databaseID) + " " + user.email + " " + user.firstName + " " + user.lastName + " " + user.contactPhone + " " + user.officePhone + " " + user.extension) self.user = user2 self.assertEqual( Terminal.viewContactInfo(self), user2.permission + " " + user2.username + " " + user2.password + " " + user2.databaseID + " " + user2.email + " " + user2.firstName + " " + user2.lastName + " " + user2.contactPhone + " " + user2.officePhone + " " + user2.extension) self.user = user3 self.assertEqual( Terminal.viewContactInfo(self), user3.permission + " " + user3.username + " " + user3.password + " " + user3.databaseID + " " + user3.email + " " + user3.firstName + " " + user3.lastName + " " + user3.contactPhone + " " + user3.officePhone + " " + user3.extension) self.user = user4 self.assertEqual( Terminal.viewContactInfo(user4.databaseID), user4.permission + " " + user4.username + " " + user4.password + " " + user4.databaseID + " " + user4.email + " " + user4.firstName + " " + user4.lastName + " " + user4.contactPhone + " " + user4.officePhone + " " + user4.extension) self.assertEqual(Terminal.viewContactInfo('fvs'), "Invalid UserID") self.assertEqual(Terminal.viewContactInfo('234'), "User Not Found")