-
-
Notifications
You must be signed in to change notification settings - Fork 493
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add User tests for UserManager.py #868
base: develop
Are you sure you want to change the base?
Changes from all commits
d592f53
f3b8d50
613ee6c
38843f8
44c033d
14807b2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# !/usr/bin/python | ||
# -*- coding: utf-8 -*- | ||
from UserManager import * | ||
import unittest | ||
import Models | ||
|
||
|
||
import unittest | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Duplicate import statement. Same as in line no:4. |
||
import testing.mysqld | ||
|
||
# Generate MYSQLD class which shares the generated database | ||
MYSQLD = testing.mysqld.MysqldFactory(cache_initialized_db=True) | ||
|
||
|
||
class User: | ||
def __init__(self, userName, email, password, auth): | ||
self.userName = userName | ||
self.email = email | ||
self.password = password | ||
self.auth = auth | ||
|
||
def userName(self): | ||
return self.userName | ||
|
||
def password(self): | ||
return self.password | ||
|
||
def email(self): | ||
return self.email | ||
|
||
def auth(self): | ||
return self.auth | ||
|
||
|
||
class Test(unittest.TestCase): | ||
def setUp(self): | ||
# Use the generated MYSQLD class instead of testing.mysqld | ||
self.mysqld = MYSQLD() | ||
|
||
def tearDown(self): | ||
self.mysqld.stop() | ||
|
||
def tearDownModule(self): | ||
# clear cached database at end of tests | ||
MYSQLD.clear_cache() | ||
|
||
def test_check_existing_username(self): | ||
self.assertEqual(True, check_user_name('rand')) | ||
|
||
def test_correct_register(self): | ||
self.assertEqual("success", add_user(user=User('normal_user', '[email protected]', '12345678', '0'))) | ||
|
||
def test_get_user(self): | ||
self.assertIsInstance(get_user('normal_user'), Models.User) | ||
|
||
def test_incorrect_regular_register_before_regular_user_register(self): | ||
self.assertEqual("username taken", | ||
add_regular_user(user=User('normal_user', '[email protected]', '12345678', '0'))) | ||
|
||
def test_correct_regular_user_register(self): | ||
self.assertEqual("success", add_regular_user(user=User('reg', '[email protected]', '12345678', '0'))) | ||
|
||
def test_incorrect_regular_register_after_regular_user_register(self): | ||
self.assertEqual("username taken", | ||
add_regular_user(user=User('reg', '[email protected]', '12345678', '0'))) | ||
|
||
def test_update_user(self): | ||
self.assertEqual("success", update_user(user=User('updated_user', '[email protected]', '12345678', '0'), | ||
username="normal_user")) | ||
|
||
def test_remove_user(self): | ||
self.assertEqual("success", remove_user('updated_user')) | ||
|
||
def test_remove_regular_user(self): | ||
self.assertEqual("success", remove_user('reg')) | ||
|
||
|
||
if __name__ == "__main__": | ||
suite = unittest.TestLoader().loadTestsFromTestCase(Test) | ||
unittest.TextTestRunner(verbosity=2).run(suite) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,7 +42,11 @@ | |
} | ||
], | ||
"dependencies": { | ||
"jasmine-core": "^2.5.2" | ||
"fsevents": "^2.1.2", | ||
"gyp": "^0.5.0", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why did the package.json changed for python tests? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these have come during the setup of the frontend. these packages were somewhat required to complete the setup otherwise a few errors were flashing. any suggestions are most welcome. |
||
"jasmine-core": "^2.5.2", | ||
"natives": "^1.1.6", | ||
"node-gyp": "^5.0.7" | ||
}, | ||
"homepage": "http://www.scorelab.org/Bassa/", | ||
"devDependencies": { | ||
|
@@ -78,7 +82,7 @@ | |
"gulp-rev": "~2.0.1", | ||
"gulp-rev-replace": "~0.3.1", | ||
"gulp-ruby-sass": "~0.7.1", | ||
"gulp-sass": "^2.3.2", | ||
"gulp-sass": "^3.1.0", | ||
"gulp-size": "~1.1.0", | ||
"gulp-uglify": "3.0.0", | ||
"gulp-uglify-es": "^1.0.4", | ||
|
@@ -96,7 +100,7 @@ | |
"karma-jasmine-html-reporter": "^0.2.2", | ||
"karma-spec-reporter": "0.0.26", | ||
"main-bower-files": "~2.4.0", | ||
"node-sass": "^4.5.0", | ||
"node-sass": "^4.13.0", | ||
"postcss": "^5.1.2", | ||
"prettier": "^1.2.2", | ||
"protractor": "~1.4.0", | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unwanted new line.