-
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.
Merge pull request #21 from ubclaunchpad/user
Add User class and properties.
- Loading branch information
Showing
3 changed files
with
167 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 |
---|---|---|
@@ -1 +1,2 @@ | ||
.idea/ | ||
.vscode/ |
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 +1,80 @@ | ||
"""Data model to represent an individual user.""" | ||
from model.permissions import Permissions | ||
|
||
|
||
class User: | ||
"""Represent a user with related fields and methods.""" | ||
|
||
__slack_id = "" | ||
__name = "" | ||
__email = "" | ||
__github_username = "" | ||
__major = "" | ||
__position = "" | ||
__biography = "" | ||
__image_url = "" | ||
__permissions_level = Permissions.member | ||
|
||
def __init__(self, slack_id): | ||
"""Initialize the user with a given Slack ID.""" | ||
self.__slack_id = slack_id | ||
|
||
def get_slack_id(self): | ||
"""Return this user's Slack ID.""" | ||
return self.__slack_id | ||
|
||
def get_email(self): | ||
"""Return this user's email.""" | ||
return self.__email | ||
|
||
def set_email(self, email): | ||
"""Set this user's email to the given argument.""" | ||
self.__email = email | ||
|
||
def get_github_username(self): | ||
"""Return this user's Github username.""" | ||
return self.__github_username | ||
|
||
def set_github_username(self, github_username): | ||
"""Set this user's Github username to the given argument.""" | ||
self.__github_username = github_username | ||
|
||
def get_major(self): | ||
"""Return this user's major.""" | ||
return self.__major | ||
|
||
def set_major(self, major): | ||
"""Set this user's major to the given argument.""" | ||
self.__major = major | ||
|
||
def get_position(self): | ||
"""Return this user's position.""" | ||
return self.__position | ||
|
||
def set_position(self, position): | ||
"""Set this user's position to the given argument.""" | ||
self.__position = position | ||
|
||
def get_biography(self): | ||
"""Return this user's biography.""" | ||
return self.__biography | ||
|
||
def set_biography(self, biography): | ||
"""Set this user's biography to the given argument.""" | ||
self.__biography = biography | ||
|
||
def get_image_url(self): | ||
"""Return this user's image URL.""" | ||
return self.__image_url | ||
|
||
def set_image_url(self, image_url): | ||
"""Set this user's image URL to the given argument.""" | ||
self.__image_url = image_url | ||
|
||
def get_permissions_level(self): | ||
"""Return this user's permissions level.""" | ||
return self.__permissions_level | ||
|
||
def set_permissions_level(self, permissions_level): | ||
"""Set this user's permissions level to the given argument.""" | ||
self.__permissions_level = permissions_level |
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,87 @@ | ||
"""Test the data model for a user.""" | ||
from model.permissions import Permissions | ||
from model.user import User | ||
|
||
|
||
def test_get_slack_id(): | ||
"""Test the User class method get_slack_id().""" | ||
user = User("U0G9QF9C6") | ||
assert user.get_slack_id() == "U0G9QF9C6" | ||
|
||
|
||
def test_get_email(): | ||
"""Test the User class method get_email().""" | ||
user = User("U0G9QF9C6") | ||
assert user.get_email() == "" | ||
|
||
|
||
def test_set_email(): | ||
"""Test the User class method set_email().""" | ||
user = User("U0G9QF9C6") | ||
user.set_email("email@example.com") | ||
assert user.get_email() == "email@example.com" | ||
|
||
|
||
def test_get_github_username(): | ||
"""Test the User class method get_github_username().""" | ||
user = User("U0G9QF9C6") | ||
assert user.get_github_username() == "" | ||
|
||
|
||
def test_set_github_username(): | ||
"""Test the User class method set_github_username().""" | ||
user = User("U0G9QF9C6") | ||
user.set_github_username("username") | ||
assert user.get_github_username() == "username" | ||
|
||
|
||
def test_get_major(): | ||
"""Test the User class method get_major().""" | ||
user = User("U0G9QF9C6") | ||
assert user.get_major() == "" | ||
|
||
|
||
def test_set_major(): | ||
"""Test the User class method set_major().""" | ||
user = User("U0G9QF9C6") | ||
user.set_major("Computer Science") | ||
assert user.get_major() == "Computer Science" | ||
|
||
|
||
def test_get_position(): | ||
"""Test the User class method get_position().""" | ||
user = User("U0G9QF9C6") | ||
assert user.get_position() == "" | ||
|
||
|
||
def test_set_position(): | ||
"""Test the User class method set_position().""" | ||
user = User("U0G9QF9C6") | ||
user.set_position("Developer") | ||
assert user.get_position() == "Developer" | ||
|
||
|
||
def test_get_image_url(): | ||
"""Test the User class method get_image_url().""" | ||
user = User("U0G9QF9C6") | ||
assert user.get_image_url() == "" | ||
|
||
|
||
def test_set_image_url(): | ||
"""Test the User class method set_image_url().""" | ||
user = User("U0G9QF9C6") | ||
user.set_image_url("https://example.com/image.jpg") | ||
assert user.get_image_url() == "https://example.com/image.jpg" | ||
|
||
|
||
def test_get_permissions_level(): | ||
"""Test the User class method get_permissions_level().""" | ||
user = User("U0G9QF9C6") | ||
assert user.get_permissions_level() == Permissions.member | ||
|
||
|
||
def test_set_permissions_level(): | ||
"""Test the User class method set_permissions_level().""" | ||
user = User("U0G9QF9C6") | ||
user.set_permissions_level(Permissions.admin) | ||
assert user.get_permissions_level() == Permissions.admin |