-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactored index.py, changed function & route names for consistency
- Loading branch information
1 parent
9e25fc2
commit c11e93a
Showing
32 changed files
with
241 additions
and
159 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,30 @@ | ||
from ResultCodes import ResultCodes | ||
|
||
resultCodes = ResultCodes() | ||
|
||
class IndexReturnDecider(): | ||
|
||
def determineSignUpRedirectPage(self, resultCode): | ||
if resultCode == resultCodes.SUCCESS: | ||
return 'signUpSuccess' | ||
elif resultCode == resultCodes.ERROR_DUPLICATE_USERNAME: | ||
return 'signUpExistingUsername' | ||
elif resultCode == resultCodes.ERROR_INVALID_USERNAME_CHARS: | ||
return 'signUpInvalidUsernameCharacters' | ||
elif resultCode == resultCodes.ERROR_USERNAME_LENGTH_INVALID: | ||
return 'signUpUsernameOutOfRange' | ||
elif resultCode == resultCodes.ERROR_PASSWORD_LENGTH_INVALID: | ||
return 'signUpPasswordOutOfRange' | ||
else: | ||
return 'signUpEmptyFields' | ||
|
||
def determineLoginRedirectPage(self, resultCode): | ||
if resultCode == resultCodes.ERROR_INVALID_USERNAME_OR_PASSWORD: | ||
return 'loginInvalidUsernameOrPassword' | ||
else: | ||
return 'loginEmptyFields' | ||
|
||
def checkIfTokenReturned(self, resultCode): | ||
if resultCode == resultCodes.SUCCESS: | ||
return True | ||
return False |
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 |
---|---|---|
@@ -1,17 +1,18 @@ | ||
|
||
class ResultCodes(): | ||
|
||
# result codes for SignupController | ||
ERROR_USERNAME_LENGTH_INVALID = 'INVALID_USERNAME_LENGTH' | ||
ERROR_PASSWORD_LENGTH_INVALID = 'INVALID_PASSWORD_LENGTH' | ||
ERROR_INVALID_USERNAME_CHARS = 'INVALID_USERNAME_CHARS' | ||
ERROR_DUPLICATE_USERNAME = 'DUPLICATE_USERNAME' | ||
ERROR_EMPTY_USERNAME = 'EMPTY_USERNAME' | ||
ERROR_EMPTY_PASSWORD = 'EMPTY_PASSWORD' | ||
ERROR_EMPTY_FIELDS = 'EMPTY_FIELDS' | ||
SUCCESS_USERNAME_PASSWORD_LENGTH = 'GOOD_USERNAME_&_PASSWORD_LENGTH' | ||
SUCCESS_FIELDS_FILLED = 'ALL_FIELDS_FILLED' | ||
SUCCESS = 'SUCCESS' | ||
# result codes for SignupHandler | ||
ERROR_USERNAME_LENGTH_INVALID = 'INVALID_USERNAME_LENGTH' | ||
ERROR_PASSWORD_LENGTH_INVALID = 'INVALID_PASSWORD_LENGTH' | ||
ERROR_INVALID_USERNAME_CHARS = 'INVALID_USERNAME_CHARS' | ||
ERROR_DUPLICATE_USERNAME = 'DUPLICATE_USERNAME' | ||
ERROR_EMPTY_USERNAME = 'EMPTY_USERNAME' | ||
ERROR_EMPTY_PASSWORD = 'EMPTY_PASSWORD' | ||
ERROR_EMPTY_FIELDS = 'EMPTY_FIELDS' | ||
SUCCESS_USERNAME_PASSWORD_LENGTH = 'GOOD_USERNAME_&_PASSWORD_LENGTH' | ||
SUCCESS_FIELDS_FILLED = 'ALL_FIELDS_FILLED' | ||
SUCCESS = 'SUCCESS' | ||
|
||
# result codes for LoginController | ||
# result codes for LoginHandler | ||
ERROR_INVALID_USERNAME_OR_PASSWORD = 'INVALID_USERNAME_OR_PASSWORD' | ||
NO_TOKEN = 'NO_TOKEN' |
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
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
Binary file renamed
BIN
+1.44 KB
..._pycache__/LoginController.cpython-36.pyc → ..._pycache__/LoginController.cpython-36.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file renamed
BIN
+1.56 KB
...pycache__/SignUpController.cpython-36.pyc → .../__pycache__/SignUpHandler.cpython-36.pyc
Binary file not shown.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file modified
BIN
+1.03 KB
(110%)
server/test/__pycache__/test_DatabaseAccessor.cpython-36-PYTEST.pyc
Binary file not shown.
Binary file added
BIN
+10.3 KB
server/test/__pycache__/test_IndexReturnDecider.cpython-36-PYTEST.pyc
Binary file not shown.
Binary file modified
BIN
+1.59 KB
(120%)
server/test/__pycache__/test_LoginController.cpython-36-PYTEST.pyc
Binary file not shown.
Binary file modified
BIN
-9 Bytes
(100%)
server/test/__pycache__/test_SignUpController.cpython-36-PYTEST.pyc
Binary file not shown.
Binary file not shown.
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
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,31 @@ | ||
import pytest | ||
import sys | ||
sys.path.append('/Users/justinkwan/Documents/WebApps/UserAuth/server/src') | ||
from IndexReturnDecider import IndexReturnDecider | ||
from ResultCodes import ResultCodes | ||
|
||
IRD = IndexReturnDecider() | ||
resultCodes = ResultCodes() | ||
|
||
def test_determineSignUpRedirectPage(): | ||
assert IRD.determineSignUpRedirectPage(resultCodes.SUCCESS) == 'signUpSuccess' | ||
assert IRD.determineSignUpRedirectPage(resultCodes.ERROR_DUPLICATE_USERNAME) == 'signUpExistingUsername' | ||
assert IRD.determineSignUpRedirectPage(resultCodes.ERROR_INVALID_USERNAME_CHARS) == 'signUpInvalidUsernameCharacters' | ||
assert IRD.determineSignUpRedirectPage(resultCodes.ERROR_USERNAME_LENGTH_INVALID) == 'signUpUsernameOutOfRange' | ||
assert IRD.determineSignUpRedirectPage(resultCodes.ERROR_PASSWORD_LENGTH_INVALID) == 'signUpPasswordOutOfRange' | ||
assert IRD.determineSignUpRedirectPage(resultCodes.ERROR_EMPTY_FIELDS) == 'signUpEmptyFields' | ||
assert IRD.determineSignUpRedirectPage(resultCodes.ERROR_EMPTY_PASSWORD) == 'signUpEmptyFields' | ||
assert IRD.determineSignUpRedirectPage(resultCodes.ERROR_EMPTY_USERNAME) == 'signUpEmptyFields' | ||
|
||
def test_determineLoginRedirectPage(): | ||
assert IRD.determineLoginRedirectPage(resultCodes.ERROR_INVALID_USERNAME_OR_PASSWORD) == 'loginInvalidUsernameOrPassword' | ||
assert IRD.determineLoginRedirectPage(resultCodes.ERROR_EMPTY_FIELDS) == 'loginEmptyFields' | ||
assert IRD.determineLoginRedirectPage(resultCodes.ERROR_EMPTY_USERNAME) == 'loginEmptyFields' | ||
assert IRD.determineLoginRedirectPage(resultCodes.ERROR_EMPTY_PASSWORD) == 'loginEmptyFields' | ||
|
||
def test_checkIfTokenReturned(): | ||
assert IRD.checkIfTokenReturned(resultCodes.SUCCESS) == True | ||
assert IRD.checkIfTokenReturned(resultCodes.ERROR_INVALID_USERNAME_OR_PASSWORD) == False | ||
assert IRD.checkIfTokenReturned(resultCodes.ERROR_EMPTY_FIELDS) == False | ||
assert IRD.checkIfTokenReturned(resultCodes.ERROR_EMPTY_USERNAME) == False | ||
assert IRD.checkIfTokenReturned(resultCodes.ERROR_EMPTY_PASSWORD) == False |
Oops, something went wrong.