-
Notifications
You must be signed in to change notification settings - Fork 119
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
User Customize Labels #946
Merged
+206
−2
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
4fa7a8d
add modes field when creating user
jiji14 3074f4e
create mode and get mode done
jiji14 42fb3b6
update modes frequency
jiji14 fdf03c2
Change return value type to string array
jiji14 7e87462
add comments
jiji14 cfacb8f
error handling when modes not exists in database
jiji14 67c4c24
add delete function, add error handling when 'modes' doesn't exist in…
jiji14 b49046c
done with unit tests
jiji14 29a4222
drop all collections when tear down
jiji14 5c8f20c
Add insert user custom mode function
jiji14 5308550
Modify the mode functions to encompass all types of labels (purpose, …
jiji14 3db594c
update UsercustomLabel test cases (mode & purpose)
jiji14 41fea13
handling an edge case when a label already exists in database
jiji14 cea1bae
combine mode and replaced_mode
jiji14 7d3f313
make the label active when updating it, in the case if it is inactive
jiji14 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
86 changes: 86 additions & 0 deletions
86
emission/tests/coreTests/wrapperTests/TestUserCustomLabel.py
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,86 @@ | ||
from __future__ import division | ||
from __future__ import unicode_literals | ||
from __future__ import print_function | ||
from __future__ import absolute_import | ||
# Standard imports | ||
from future import standard_library | ||
standard_library.install_aliases() | ||
from builtins import * | ||
import unittest | ||
|
||
# Our imports | ||
from emission.core.wrapper.user import User | ||
import emission.tests.common as etc | ||
import emission.core.get_database as edb | ||
|
||
import emission.tests.common as etc | ||
|
||
class TestUserCustomMode(unittest.TestCase): | ||
|
||
def setUp(self): | ||
self.user = User.register('[email protected]') | ||
|
||
def testInitialGetUserCustomLabels(self): | ||
self.assertListEqual(self.user.getUserCustomLabel('mode'), []) | ||
self.assertListEqual(self.user.getUserCustomLabel('purpose'), []) | ||
|
||
def testInsertCustomLabel(self): | ||
inserted_mode = { | ||
'key' : 'mode', | ||
'label' : 'mode1', | ||
} | ||
mode = self.user.insertUserCustomLabel(inserted_mode) | ||
self.assertListEqual(mode, ['mode1']) | ||
|
||
inserted_purpose = { | ||
'key' : 'purpose', | ||
'label' : 'purpose1', | ||
} | ||
purpose = self.user.insertUserCustomLabel(inserted_purpose) | ||
self.assertListEqual(purpose, ['purpose1']) | ||
|
||
def tesUpdateUserCustomLabel(self): | ||
self.testInsertCustomLabel() | ||
updated_mode = { | ||
'key' : 'mode', | ||
'old_label' : '', | ||
'new_label' : 'mode2', | ||
'is_new_label_must_added': True | ||
} | ||
mode = self.user.updateUserCustomLabel(updated_mode) | ||
self.assertListEqual(mode, ['mode2', 'mode1']) | ||
|
||
updated_purpose = { | ||
'key' : 'purpose', | ||
'old_label' : '', | ||
'new_label' : 'purpose2', | ||
'is_new_label_must_added': True | ||
} | ||
purpose = self.user.updateUserCustomLabel(updated_purpose) | ||
self.assertListEqual(purpose, ['purpose2', 'purpose1']) | ||
|
||
def testDeleteUserCustomMode(self): | ||
self.tesUpdateUserCustomLabel() | ||
deleted_mode = { | ||
'key' : 'mode', | ||
'label' : 'mode2', | ||
} | ||
mode = self.user.deleteUserCustomLabel(deleted_mode) | ||
|
||
self.assertListEqual(mode, ['mode1']) | ||
|
||
deleted_purpose = { | ||
'key' : 'purpose', | ||
'label' : 'purpose2', | ||
} | ||
purpose = self.user.deleteUserCustomLabel(deleted_purpose) | ||
self.assertListEqual(purpose, ['purpose1']) | ||
|
||
def tearDown(self): | ||
etc.dropAllCollections(edb._get_current_db()) | ||
|
||
|
||
if __name__ == '__main__': | ||
etc.configLogging() | ||
unittest.main() | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
nit: can eventually remove this
source
since it is hardcoded and never used. I don't remember the full history (will need to check the blame) but IIRC, it was an early attempt at multi-tenancy (e.g. users from my team versus from other teams at Berkeley)