Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
AmendsenProject
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Shaik Janipasha
AmendsenProject
Commits
a47f9adc
Unverified
Commit
a47f9adc
authored
Mar 24, 2020
by
Tao Feng
Committed by
GitHub
Mar 24, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add title field in user model (#227)
* Add title field in user model * fix one more test
parent
2cfa2469
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
14 deletions
+24
-14
user.py
databuilder/models/user.py
+17
-11
setup.py
setup.py
+1
-1
test_table_column_usage.py
tests/unit/models/test_table_column_usage.py
+2
-1
test_user.py
tests/unit/models/test_user.py
+4
-1
No files found.
databuilder/models/user.py
View file @
a47f9adc
...
...
@@ -25,6 +25,7 @@ class User(Neo4jCsvSerializable):
USER_NODE_SLACK_ID
=
'slack_id'
USER_NODE_IS_ACTIVE
=
'is_active{}'
.
format
(
UNQUOTED_SUFFIX
)
# bool value needs to be unquoted when publish to neo4j
USER_NODE_UPDATED_AT
=
'updated_at'
USER_NODE_TITLE
=
'title'
USER_MANAGER_RELATION_TYPE
=
'MANAGE_BY'
MANAGER_USER_RELATION_TYPE
=
'MANAGE'
...
...
@@ -41,6 +42,7 @@ class User(Neo4jCsvSerializable):
slack_id
=
''
,
# type: str
is_active
=
True
,
# type: bool
updated_at
=
0
,
# type: int
title
=
''
,
# type: str
**
kwargs
# type: Dict
):
# type: (...) -> None
...
...
@@ -59,6 +61,7 @@ class User(Neo4jCsvSerializable):
:param updated_at: everytime we update the node, we will push the timestamp.
then we will have a cron job to update the ex-employee nodes based on
the case if this timestamp hasn't been updated for two weeks.
:param title: the title of the user (e.g swe)
:param kwargs: Any K/V attributes we want to update the
"""
self
.
first_name
=
first_name
...
...
@@ -75,6 +78,7 @@ class User(Neo4jCsvSerializable):
self
.
slack_id
=
slack_id
self
.
is_active
=
is_active
self
.
updated_at
=
updated_at
self
.
title
=
title
self
.
attrs
=
None
if
kwargs
:
self
.
attrs
=
copy
.
deepcopy
(
kwargs
)
...
...
@@ -129,6 +133,7 @@ class User(Neo4jCsvSerializable):
result_node
[
User
.
USER_NODE_EMPLOYEE_TYPE
]
=
self
.
employee_type
if
self
.
employee_type
else
''
result_node
[
User
.
USER_NODE_SLACK_ID
]
=
self
.
slack_id
if
self
.
slack_id
else
''
result_node
[
User
.
USER_NODE_UPDATED_AT
]
=
self
.
updated_at
if
self
.
updated_at
else
0
result_node
[
User
.
USER_NODE_TITLE
]
=
self
.
title
if
self
.
title
else
''
if
self
.
attrs
:
for
k
,
v
in
self
.
attrs
.
items
():
...
...
@@ -154,14 +159,15 @@ class User(Neo4jCsvSerializable):
def
__repr__
(
self
):
# type: () -> str
return
'User({!r}, {!r}, {!r}, {!r}, {!r}, '
\
'{!r}, {!r}, {!r}, {!r}, {!r}, {!r},)'
.
format
(
self
.
first_name
,
self
.
last_name
,
self
.
name
,
self
.
email
,
self
.
github_username
,
self
.
team_name
,
self
.
slack_id
,
self
.
manager_email
,
self
.
employee_type
,
self
.
is_active
,
self
.
updated_at
)
'{!r}, {!r}, {!r}, {!r}, {!r}, {!r}, {!r})'
.
format
(
self
.
first_name
,
self
.
last_name
,
self
.
name
,
self
.
email
,
self
.
github_username
,
self
.
team_name
,
self
.
slack_id
,
self
.
manager_email
,
self
.
employee_type
,
self
.
is_active
,
self
.
updated_at
,
self
.
title
)
setup.py
View file @
a47f9adc
...
...
@@ -2,7 +2,7 @@ import os
from
setuptools
import
setup
,
find_packages
__version__
=
'2.4.
0
'
__version__
=
'2.4.
1
'
requirements_path
=
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
)),
'requirements.txt'
)
with
open
(
requirements_path
)
as
requirements_file
:
...
...
tests/unit/models/test_table_column_usage.py
View file @
a47f9adc
...
...
@@ -31,7 +31,8 @@ class TestTableColumnUsage(unittest.TestCase):
'KEY'
:
'john@example.com'
,
'github_username'
:
''
,
'team_name'
:
''
,
'email'
:
'john@example.com'
}]
'email'
:
'john@example.com'
,
'title'
:
''
}]
self
.
assertEqual
(
expected
,
actual
)
rel_row
=
table_col_usage
.
next_relation
()
...
...
tests/unit/models/test_user.py
View file @
a47f9adc
...
...
@@ -21,7 +21,8 @@ class TestUser(unittest.TestCase):
manager_email
=
'test_manager@email.com'
,
slack_id
=
'slack'
,
is_active
=
True
,
updated_at
=
1
)
updated_at
=
1
,
title
=
'swe'
)
def
test_get_user_model_key
(
self
):
# type: () -> None
...
...
@@ -45,11 +46,13 @@ class TestUser(unittest.TestCase):
slack_id
=
'slack'
,
is_active
=
True
,
updated_at
=
1
,
title
=
'swe'
,
role
=
'SWE'
,
enable_notify
=
True
)
nodes
=
test_user
.
create_nodes
()
self
.
assertEqual
(
nodes
[
0
][
'email'
],
'test@email.com'
)
self
.
assertEqual
(
nodes
[
0
][
'role'
],
'SWE'
)
self
.
assertEqual
(
nodes
[
0
][
'title'
],
'swe'
)
self
.
assertTrue
(
nodes
[
0
][
'enable_notify'
])
def
test_create_relation
(
self
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment