This repository has been archived by the owner on Dec 12, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c5e28c5
commit 4bd83be
Showing
3 changed files
with
223 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
var log = require('../models/login'); | ||
|
||
// Test Case #1 - Valid Username and Valid Password | ||
var username1 = "[email protected]"; | ||
var password1 = "soen341"; | ||
var testLogin = function(login, username, password) { | ||
if (login(username, password) != undefined) { | ||
console.log('Test Case #1 Passed!'); | ||
} else { | ||
console.log('Test Case #1 Failed!'); | ||
} | ||
} | ||
testLogin(log.login, username1, password1); | ||
log.logout(); //Making sure it's logged out before next test | ||
|
||
// Test Case #2 - Invalid Username and Valid Password | ||
var username2 = "[email protected]"; | ||
var password2 = "soen341"; | ||
var testLogin = function(login, username, password) { | ||
if (login(username, password) != undefined) { | ||
console.log('Test Case #2 Passed!'); | ||
} else { | ||
console.log('Test Case #2 Failed!'); | ||
} | ||
} | ||
testLogin(log.login, username2, password2); | ||
log.logout(); //Making sure it's logged out before next test | ||
|
||
|
||
|
||
|
||
// Test Case #3 - Valid Username and Invalid Password | ||
var username3 = "[email protected]"; | ||
var password3 = "inconnectpassword"; | ||
var testLogin = function(login, username, password) { | ||
if (login(username, password) != undefined) { | ||
console.log('Test Case #2 Passed!'); | ||
} else { | ||
console.log('Test Case #2 Failed!'); | ||
} | ||
} | ||
testLogin(log.login, username3, password3); | ||
log.logout(); //Making sure it's logged out before next test | ||
|
||
// EXPECTED OUTPUT | ||
// Test Case #1 Passed! | ||
// Test Case #2 Failed! | ||
// Test Case #3 Failed! | ||
|
||
// Test Case #4 - User is logged in, tries logout | ||
var username4 = "[email protected]"; | ||
var password4 = "soen341"; | ||
log.login(username4, password4); //Login correctly first | ||
var testLogout = function(logout) { | ||
if (logout() != undefined) { | ||
console.log('Test Case #4 Passed!'); | ||
} else { | ||
console.log('Test Case #4 Failed!') | ||
} | ||
} | ||
testLogout(log.logout); | ||
|
||
// Test Case #5 - User that is NOT logged in, tries to logout | ||
var testLogout = function(logout) { | ||
if (logout() != undefined) { | ||
console.log('Test Case #5 Passed!'); | ||
} else { | ||
console.log('Test Case #5 Failed!') | ||
} | ||
} | ||
testLogout(log.logout); | ||
|
||
// Test Case #6 - User is logged in, test to check whether he is logged in or not | ||
var username6 = "[email protected]"; | ||
var password6 = "soen341"; | ||
log.login(username6, password6); | ||
var testIsLoggedIn = function(isLoggedIn) { | ||
if (isLoggedIn() != undefined) { | ||
console.log('Test Case #6 Passed!'); | ||
} else { | ||
console.log('Test Case #6 Failed!') | ||
} | ||
} | ||
testIsLoggedIn(log.isLoggedIn); | ||
log.logout(); //Making sure it's logged out before next test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
var _ = require('underscore'); | ||
var course = require('../models/course'); | ||
|
||
// Test Case #1 - course has one sections | ||
var courseWithOneSection = Object.create(course.id = 'SOEN492'); | ||
var testGetAssociatedSections = function(getAssociatedSections) { | ||
if (getAssociatedSections() !== undefined && | ||
getAssociatedSections().length === 1 && | ||
typeof getAssociatedSections() === section) { | ||
console.log('Test Case #1 Passed!'); | ||
} else { | ||
console.log('Test Case #1 Failed!'); | ||
} | ||
}; | ||
testGetAssociatedSections(courseWithOneSection.getAssociatedSections); | ||
|
||
|
||
// Test Case #2 - course has multiple sections | ||
var courseWithMultipleSections = Object.create(course.id = 'SOEN341'); | ||
var testCourseWithMultipleSections = function(getAssociatedSections) { | ||
if (getAssociatedSections() !== undefined && | ||
getAssociatedSections().length > 1 && | ||
getAssociatedSections().map(function(i) { | ||
return typeof i === section | ||
})) { | ||
console.log('Test Case #2 Passed!'); | ||
} else { | ||
console.log('Test Case #2 Failed!'); | ||
} | ||
}; | ||
testGetAssociatedSections(courseWithMultipleSections.getAssociatedSections); | ||
|
||
// Test Case #3 - course has no sections | ||
var courseWithNoSections = Object.create(course.id = 'SOEN3074'); | ||
var testCourseWithNoSections = function(getAssociatedSections) { | ||
if (getAssociatedSections() !== undefined && | ||
getAssociatedSections().length >= 1 && | ||
getAssociatedSections().map(function(i) { | ||
return typeof i === section | ||
})) { | ||
console.log('Test Case #3 Passed!'); | ||
} else { | ||
console.log('Test Case #3 Failed!'); | ||
} | ||
} | ||
testCourseWithNoSections(courseWithNoSections.getAssociatedSections); | ||
|
||
// EXPECTED OUTPUT | ||
// Test Case #1 Passed! | ||
// Test Case #2 Passed! | ||
// Test Case #3 Failed! | ||
|
||
// Test Case #4 - All Sections exists | ||
var allSectionsExist = Object.create(course.id = 'SOEN341'); | ||
var testListSectionTimes = function(course) { | ||
if (course.listSectionTimes(course.getAssociatedSections) !== undefined && | ||
course.listSectionTimes(course.getAssociatedSections).length > 0 && | ||
_.isEqual(course.listSectionTimes(course.getAssociatedSections), ['H HA', 'H HB'])) { | ||
console.log('Test Case #4 Passed!'); | ||
} else { | ||
console.log('Test Case #4 Failed!'); | ||
} | ||
} | ||
testAllSectionsExist(allSectionsExist); | ||
|
||
// Test Case #5 - At least one section doesn't exist | ||
var sectionDoesntExist = Object.create(course.id = 'SOEN341'); | ||
var testSectionDoesntExist = function(course) { | ||
if (course.listSectionTimes(course.getAssociatedSections) !== undefined && | ||
course.listSectionTimes(course.getAssociatedSections).length > 0 && | ||
_.isEqual(course.listSectionTimes(course.getAssociatedSections), ['H HA', 'H HB'])) { | ||
console.log('Test Case #5 Passed!'); | ||
} else { | ||
console.log('Test Case #5 Failed!'); | ||
} | ||
} | ||
testSectionDoesntExist(sectionDoesntExist); | ||
|
||
// EXPECTED OUTPUT | ||
// Test Case #4 Passed! | ||
// Test Case #5 Failed! | ||
|
||
// Test Case #6 - Course has correct credits | ||
var realCourse = Object.create(course.id = 'SOEN341'); | ||
var testCourseCredits = function(courseCredits) { | ||
if (courseCredits() !== undefined && | ||
typeOf courseCredits() === "number" && | ||
courseCredits() === 3) { | ||
console.log('Test Case #6 Passed!'); | ||
} else { | ||
console.log('Test Case #6 Failed!'); | ||
} | ||
}; | ||
testCourseCredits(realCourse.courseCredits); | ||
|
||
// Test Case #7 - Non-existant course does not have credits | ||
var fakeCourse = Object.create(course.id = 'SOEN3411w3r'); | ||
var testCourseCredits = function(courseCredits) { | ||
if (courseCredits() !== undefined && | ||
typeOf courseCredits() === "number") { | ||
console.log('Test Case #7 Passed!'); | ||
} else { | ||
console.log('Test Case #7 Failed!'); | ||
} | ||
}; | ||
testCourseCredits(fakeCourse.courseCredits); | ||
|
||
// EXPECTED OUTPUT | ||
// Test Case #6 Passed! | ||
// Test Case #7 Failed! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import urllib.request | ||
import time | ||
|
||
numOfRequests = 10000 | ||
|
||
def makeRequests(numOfRequests): | ||
for index in range(numOfRequests): | ||
f = urllib.request.urlopen('http://159.203.40.62:3000') | ||
if index == 0: | ||
initialCode = f.getcode() | ||
if index == numOfRequests - 1: | ||
endCode = f.getcode() | ||
index += 1 | ||
return [initialCode, endCode] | ||
|
||
print('Stress testing web application. Please wait...') | ||
startTime = time.time() | ||
results = makeRequests(numOfRequests); | ||
elapsedTime = time.time() - startTime | ||
|
||
requestsPerSecond = numOfRequests / elapsedTime | ||
systemIsUp = results[0] == results[1] | ||
|
||
print('---') | ||
print('Numer of requests: ' + str(numOfRequests)) | ||
print('Number of seconds: ' + str(elapsedTime)) | ||
print('Number of requests per second: ' + str(requestsPerSecond)) | ||
print('System is still operational: '+ str(systemIsUp)) |