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
36ba5d26
Unverified
Commit
36ba5d26
authored
Apr 11, 2019
by
Daniel
Committed by
GitHub
Apr 11, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup test code for Amundsen People (#73)
parent
7b09a2fa
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
8 additions
and
180 deletions
+8
-180
v0.py
amundsen_application/api/metadata/v0.py
+2
-27
v0.py
amundsen_application/api/search/v0.py
+2
-72
index.tsx
amundsen_application/static/js/components/NavBar/index.tsx
+1
-3
index.tsx
...sen_application/static/js/components/SearchPage/index.tsx
+1
-6
v0.ts
amundsen_application/static/js/ducks/search/api/v0.ts
+2
-4
test_v0.py
tests/unit/api/search/test_v0.py
+0
-68
No files found.
amundsen_application/api/metadata/v0.py
View file @
36ba5d26
...
@@ -555,32 +555,7 @@ def update_table_tags() -> Response:
...
@@ -555,32 +555,7 @@ def update_table_tags() -> Response:
return
make_response
(
payload
,
HTTPStatus
.
INTERNAL_SERVER_ERROR
)
return
make_response
(
payload
,
HTTPStatus
.
INTERNAL_SERVER_ERROR
)
# TODO: Implement
real support
# TODO: Implement
@
metadata_blueprint
.
route
(
'/user'
,
methods
=
[
'GET'
])
@
metadata_blueprint
.
route
(
'/user'
,
methods
=
[
'GET'
])
def
get_user
()
->
Response
:
def
get_user
()
->
Response
:
try
:
return
make_response
(
jsonify
({
'msg'
:
'Not implemented'
}),
HTTPStatus
.
NOT_IMPLEMENTED
)
user_id
=
get_query_param
(
request
.
args
,
'user_id'
)
user_info
=
{
'first_name'
:
'Firstname'
,
'last_name'
:
'Lastname'
,
'email'
:
'test@test.com'
,
'display_name'
:
'Firstname Lastname'
,
'profile_url'
:
'https://github.com/lyft/amundsenfrontendlibrary'
,
'user_id'
:
user_id
,
'github_name'
:
'lyft'
,
'is_active'
:
True
,
'manager_name'
:
'Roald Amundsen'
,
'role_name'
:
'Software Engineer'
,
'slack_url'
:
'https://slack.com'
,
'team_name'
:
'Amundsen Team'
,
}
if
user_id
==
'alumni'
:
user_info
[
'is_active'
]
=
False
status_code
=
HTTPStatus
.
OK
payload
=
jsonify
({
'user'
:
user_info
})
return
make_response
(
payload
,
status_code
)
except
Exception
as
e
:
message
=
'Encountered exception: '
+
str
(
e
)
logging
.
exception
(
message
)
return
make_response
(
jsonify
({
'user'
:
{},
'msg'
:
message
}),
HTTPStatus
.
INTERNAL_SERVER_ERROR
)
amundsen_application/api/search/v0.py
View file @
36ba5d26
...
@@ -28,7 +28,7 @@ valid_search_fields = {
...
@@ -28,7 +28,7 @@ valid_search_fields = {
def
_create_error_response
(
*
,
message
:
str
,
payload
:
Dict
,
status_code
:
int
)
->
Response
:
def
_create_error_response
(
*
,
message
:
str
,
payload
:
Dict
,
status_code
:
int
)
->
Response
:
logging
.
info
(
message
)
logging
.
info
(
message
)
payload
[
'mg'
]
=
message
payload
[
'm
s
g'
]
=
message
return
make_response
(
jsonify
(
payload
),
status_code
)
return
make_response
(
jsonify
(
payload
),
status_code
)
...
@@ -68,15 +68,7 @@ def search_table() -> Response:
...
@@ -68,15 +68,7 @@ def search_table() -> Response:
@
search_blueprint
.
route
(
'/user'
,
methods
=
[
'GET'
])
@
search_blueprint
.
route
(
'/user'
,
methods
=
[
'GET'
])
def
search_user
()
->
Response
:
def
search_user
()
->
Response
:
search_term
=
get_query_param
(
request
.
args
,
'query'
,
'Endpoint takes a "query" parameter'
)
return
make_response
(
jsonify
({
'msg'
:
'Not implemented'
}),
HTTPStatus
.
NOT_IMPLEMENTED
)
page_index
=
get_query_param
(
request
.
args
,
'page_index'
,
'Endpoint takes a "page_index" parameter'
)
error_response
=
_validate_search_term
(
search_term
=
search_term
,
page_index
=
int
(
page_index
))
if
error_response
is
not
None
:
return
error_response
results_dict
=
_search_user
(
search_term
=
search_term
,
page_index
=
page_index
)
return
make_response
(
jsonify
(
results_dict
),
results_dict
.
get
(
'status_code'
,
HTTPStatus
.
INTERNAL_SERVER_ERROR
))
def
_create_url_with_field
(
*
,
search_term
:
str
,
page_index
:
int
)
->
str
:
def
_create_url_with_field
(
*
,
search_term
:
str
,
page_index
:
int
)
->
str
:
...
@@ -157,68 +149,6 @@ def _search_user(*, search_term: str, page_index: int) -> Dict[str, Any]:
...
@@ -157,68 +149,6 @@ def _search_user(*, search_term: str, page_index: int) -> Dict[str, Any]:
'users'
:
users
,
'users'
:
users
,
}
}
# TEST CODE
users
[
'total_results'
]
=
3
users
[
'results'
]
=
[
{
'type'
:
'user'
,
'active'
:
True
,
'birthday'
:
'10-10-2000'
,
'department'
:
'Department'
,
'email'
:
'mail@address.com'
,
'first_name'
:
'Ash'
,
'github_username'
:
'github_user'
,
'id'
:
12345
,
'last_name'
:
'Ketchum'
,
'manager_email'
:
'manager_email'
,
'name'
:
'Ash Ketchum'
,
'offboarded'
:
False
,
'office'
:
'Kanto Region'
,
'role'
:
'Pokemon Trainer'
,
'start_date'
:
'05-04-2016'
,
'team_name'
:
'Kanto Trainers'
,
'title'
:
'Pokemon Master'
,
},
{
'type'
:
'user'
,
'active'
:
True
,
'birthday'
:
'06-01-2000'
,
'department'
:
'Department'
,
'email'
:
'mail@address.com'
,
'first_name'
:
'Gary'
,
'github_username'
:
'github_user'
,
'id'
:
12345
,
'last_name'
:
'Oak'
,
'manager_email'
:
'manager_email'
,
'name'
:
'Gary Oak'
,
'offboarded'
:
False
,
'office'
:
'Kanto Region'
,
'role'
:
'Pokemon Trainer'
,
'start_date'
:
'05-04-2016'
,
'team_name'
:
'Kanto Trainers'
,
'title'
:
'Pokemon Master'
,
},
{
'type'
:
'user'
,
'active'
:
False
,
'birthday'
:
'06-01-60'
,
'department'
:
'Department'
,
'email'
:
'mail@address.com'
,
'first_name'
:
'Professor'
,
'github_username'
:
'github_user'
,
'id'
:
12345
,
'last_name'
:
'Oak'
,
'manager_email'
:
'manager_email'
,
'name'
:
'Professor Oak'
,
'offboarded'
:
False
,
'office'
:
'Kanto Region'
,
'role'
:
'Scientist'
,
'start_date'
:
'05-04-2016'
,
'team_name'
:
'Team Oak'
,
'title'
:
'Pokemon Researcher'
,
},
]
return
results_dict
return
results_dict
...
...
amundsen_application/static/js/components/NavBar/index.tsx
View file @
36ba5d26
...
@@ -70,11 +70,9 @@ export class NavBar extends React.Component<NavBarProps, NavBarState> {
...
@@ -70,11 +70,9 @@ export class NavBar extends React.Component<NavBarProps, NavBarState> {
})
})
}
}
{
{
// TODO PEOPLE - Add link to user profile
this
.
state
.
loggedInUser
&&
this
.
state
.
loggedInUser
&&
// TODO PEOPLE - Uncomment when enabling people
//<Link to=
{
`/user/${this.state.loggedInUser.user_id}`
}
>
<
Avatar
name=
{
this
.
state
.
loggedInUser
.
display_name
}
size=
{
32
}
round=
{
true
}
/>
<
Avatar
name=
{
this
.
state
.
loggedInUser
.
display_name
}
size=
{
32
}
round=
{
true
}
/>
//</Link>
}
}
</
div
>
</
div
>
</
div
>
</
div
>
...
...
amundsen_application/static/js/components/SearchPage/index.tsx
View file @
36ba5d26
...
@@ -178,12 +178,7 @@ export class SearchPage extends React.Component<SearchPageProps, SearchPageState
...
@@ -178,12 +178,7 @@ export class SearchPage extends React.Component<SearchPageProps, SearchPageState
key
:
ResourceType
.
table
,
key
:
ResourceType
.
table
,
content
:
this
.
getTabContent
(
this
.
props
.
tables
,
'tables'
),
content
:
this
.
getTabContent
(
this
.
props
.
tables
,
'tables'
),
},
},
// TODO PEOPLE - Uncomment when enabling people
// TODO PEOPLE - Add users tab
// {
// title: `Users (${ this.props.users.total_results })`,
// key: ResourceType.user,
// content: this.getTabContent(this.props.users, 'users'),
// },
];
];
return
(
return
(
...
...
amundsen_application/static/js/ducks/search/api/v0.ts
View file @
36ba5d26
...
@@ -9,13 +9,11 @@ export function searchAll(action: SearchAllRequest) {
...
@@ -9,13 +9,11 @@ export function searchAll(action: SearchAllRequest) {
const
{
term
,
options
}
=
action
;
const
{
term
,
options
}
=
action
;
return
axios
.
all
([
return
axios
.
all
([
axios
.
get
(
`
${
BASE_URL
}
/table?query=
${
term
}
&page_index=
${
options
.
tableIndex
||
0
}
`
),
axios
.
get
(
`
${
BASE_URL
}
/table?query=
${
term
}
&page_index=
${
options
.
tableIndex
||
0
}
`
),
// TODO PEOPLE - Uncomment when enabling People feature
// TODO PEOPLE - Add request for people here
// axios.get(`${BASE_URL}/user?query=${term}&page_index=${options.userIndex || 0}`),
]).
then
(
axios
.
spread
((
tableResponse
:
AxiosResponse
<
SearchResponse
>
)
=>
{
]).
then
(
axios
.
spread
((
tableResponse
:
AxiosResponse
<
SearchResponse
>
/*, userResponse: AxiosResponse<SearchResponse>*/
)
=>
{
return
{
return
{
search_term
:
tableResponse
.
data
.
search_term
,
search_term
:
tableResponse
.
data
.
search_term
,
tables
:
tableResponse
.
data
.
tables
,
tables
:
tableResponse
.
data
.
tables
,
// users: userResponse.data.users,
}
}
})).
catch
((
error
:
AxiosError
)
=>
{
})).
catch
((
error
:
AxiosError
)
=>
{
// TODO - handle errors
// TODO - handle errors
...
...
tests/unit/api/search/test_v0.py
View file @
36ba5d26
...
@@ -200,71 +200,3 @@ class SearchTest(unittest.TestCase):
...
@@ -200,71 +200,3 @@ class SearchTest(unittest.TestCase):
'/hive?page_index=1'
'/hive?page_index=1'
self
.
assertEqual
(
_create_url_with_field
(
search_term
=
search_term
,
self
.
assertEqual
(
_create_url_with_field
(
search_term
=
search_term
,
page_index
=
1
),
expected
)
page_index
=
1
),
expected
)
# ----- User Search Tests ---- #
def
test_search_user_fail_if_no_query
(
self
)
->
None
:
"""
Test request failure if 'query' is not provided in the query string
to the search endpoint
:return:
"""
with
local_app
.
test_client
()
as
test
:
response
=
test
.
get
(
'/api/search/v0/user'
,
query_string
=
dict
(
page_index
=
'0'
))
self
.
assertEqual
(
response
.
status_code
,
HTTPStatus
.
INTERNAL_SERVER_ERROR
)
def
test_search_user_fail_if_no_page_index
(
self
)
->
None
:
"""
Test request failure if 'page_index' is not provided in the query string
to the search endpoint
:return:
"""
with
local_app
.
test_client
()
as
test
:
response
=
test
.
get
(
'/api/search/v0/user'
,
query_string
=
dict
(
query
=
'test'
))
self
.
assertEqual
(
response
.
status_code
,
HTTPStatus
.
INTERNAL_SERVER_ERROR
)
# TODO - Uncomment test once the API is integrated
# @responses.activate
# def test_search_user_success(self) -> None:
# """
# Test request success
# :return:
# """
# responses.add(responses.GET, local_app.config['SEARCHSERVICE_ENDPOINT'],
# json=self.mock_search_table_results, status=HTTPStatus.OK)
#
# with local_app.test_client() as test:
# response = test.get('/api/search/v0/user', query_string=dict(query='test', page_index='0'))
# data = json.loads(response.data)
# self.assertEqual(response.status_code, HTTPStatus.OK)
#
# users = data.get('users')
# self.assertEqual(users.get('total_results'), self.mock_search_table_results.get('total_results'))
# self.assertCountEqual(users.get('results'), self.expected_parsed_search_table_results)
# @responses.activate
# def test_search_user_fail_on_non_200_response(self) -> None:
# """
# Test request failure if search endpoint returns non-200 http code
# :return:
# """
# responses.add(responses.GET, local_app.config['SEARCHSERVICE_ENDPOINT'],
# json=self.mock_search_table_results, status=HTTPStatus.INTERNAL_SERVER_ERROR)
#
# with local_app.test_client() as test:
# response = test.get('/api/search/v0/user', query_string=dict(query='test', page_index='0'))
# self.assertEqual(response.status_code, HTTPStatus.INTERNAL_SERVER_ERROR)
@
responses
.
activate
def
test_search_user_fail_on_proccessing_bad_response
(
self
)
->
None
:
"""
Test catching exception if there is an error processing the results
from the search endpoint
:return:
"""
responses
.
add
(
responses
.
GET
,
local_app
.
config
[
'SEARCHSERVICE_ENDPOINT'
],
json
=
self
.
bad_search_results
,
status
=
HTTPStatus
.
OK
)
with
local_app
.
test_client
()
as
test
:
response
=
test
.
get
(
'/api/search/v0/table'
,
query_string
=
dict
(
query
=
'test'
,
page_index
=
'0'
))
self
.
assertEqual
(
response
.
status_code
,
HTTPStatus
.
INTERNAL_SERVER_ERROR
)
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