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
fa99d9bb
Unverified
Commit
fa99d9bb
authored
Mar 17, 2020
by
Tamika Tannis
Committed by
GitHub
Mar 17, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up some tests; Create constant for hardcoded text (#407)
parent
ef49b887
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
66 additions
and
118 deletions
+66
-118
config.py
amundsen_application/config.py
+0
-6
index.spec.tsx
...mponents/TableDetail/EditableSection/tests/index.spec.tsx
+9
-9
constants.ts
...application/static/js/components/TableDetail/constants.ts
+1
-0
index.tsx
...en_application/static/js/components/TableDetail/index.tsx
+6
-3
test_metadata_utils.py
tests/unit/utils/test_metadata_utils.py
+50
-100
No files found.
amundsen_application/config.py
View file @
fa99d9bb
...
...
@@ -115,12 +115,6 @@ class TestConfig(LocalConfig):
ISSUE_TRACKER_CLIENT_ENABLED
=
True
ISSUE_TRACKER_MAX_RESULTS
=
3
PROGRAMMATIC_DISPLAY
=
{
"a_1"
:
{
"display_order"
:
0
}
}
class
TestNotificationsDisabledConfig
(
LocalConfig
):
AUTH_USER_METHOD
=
get_test_user
...
...
amundsen_application/static/js/components/TableDetail/EditableSection/tests/index.spec.tsx
View file @
fa99d9bb
...
...
@@ -46,11 +46,15 @@ describe("EditableSection", () => {
});
describe
(
"render"
,
()
=>
{
const
customTitle
=
"custom title"
;
const
{
wrapper
,
props
}
=
setup
({
title
:
customTitle
},
<
TagInput
/>);
it
(
"sets the title from a prop"
,
()
=>
{
expect
(
wrapper
.
find
(
".section-title"
).
text
()).
toBe
(
"Custom Title"
);
const
mockTitle
=
'Mock'
;
const
convertTextSpy
=
jest
.
spyOn
(
EditableSection
,
'convertText'
).
mockImplementation
(()
=>
mockTitle
);
const
{
wrapper
,
props
}
=
setup
({
title
:
'custom title'
},
<
TagInput
/>);
it
(
"renders the converted props.title as the section title"
,
()
=>
{
convertTextSpy
.
mockClear
();
wrapper
.
instance
().
render
();
expect
(
convertTextSpy
).
toHaveBeenCalledWith
(
props
.
title
);
expect
(
wrapper
.
find
(
".section-title"
).
text
()).
toBe
(
mockTitle
);
});
it
(
"renders children with additional props"
,
()
=>
{
...
...
@@ -75,9 +79,5 @@ describe("EditableSection", () => {
const
{
wrapper
}
=
setup
({
readOnly
:
true
},
<
TagInput
/>);
expect
(
wrapper
.
find
(
".edit-button"
).
length
).
toEqual
(
0
);
});
it
(
'renders modifies title to have no underscores'
,
()
=>
{
expect
(
EditableSection
.
convertText
(
"testing_a123_b456 c789"
)).
toEqual
(
"Testing A123 B456 C789"
)
})
});
});
amundsen_application/static/js/components/TableDetail/constants.ts
0 → 100644
View file @
fa99d9bb
export
const
PROGRMMATIC_DESC_HEADER
=
'Read-only information, auto-generated'
amundsen_application/static/js/components/TableDetail/index.tsx
View file @
fa99d9bb
...
...
@@ -15,6 +15,7 @@ import BookmarkIcon from 'components/common/Bookmark/BookmarkIcon';
import
Breadcrumb
from
'components/common/Breadcrumb'
;
import
DataPreviewButton
from
'components/TableDetail/DataPreviewButton'
;
import
ColumnList
from
'components/TableDetail/ColumnList'
;
import
EditableText
from
'components/common/EditableText'
;
import
ExploreButton
from
'components/TableDetail/ExploreButton'
;
import
Flag
from
'components/common/Flag'
;
import
FrequentUsers
from
'components/TableDetail/FrequentUsers'
;
...
...
@@ -40,7 +41,8 @@ import { formatDateTimeShort } from 'utils/dateUtils';
import
'./styles'
;
import
RequestDescriptionText
from
'./RequestDescriptionText'
;
import
RequestMetadataForm
from
'./RequestMetadataForm'
;
import
EditableText
from
"components/common/EditableText"
;
import
{
PROGRMMATIC_DESC_HEADER
}
from
'./constants'
;
export
interface
StateFromProps
{
isLoading
:
boolean
;
...
...
@@ -211,9 +213,10 @@ class TableDetail extends React.Component<TableDetailProps & RouteComponentProps
</
EditableSection
>
</
section
>
</
section
>
{
data
.
programmatic_descriptions
.
length
>
0
&&
{
data
.
programmatic_descriptions
.
length
>
0
&&
<>
<
div
className=
"programmatic-title title-4"
>
Read-Only information, Auto-Generated.
</
div
>
<
div
className=
"programmatic-title title-4"
>
{
PROGRMMATIC_DESC_HEADER
}
</
div
>
<
hr
className=
"programmatic-hr hr1"
/>
</>
}
...
...
tests/unit/utils/test_metadata_utils.py
View file @
fa99d9bb
import
unittest
from
amundsen_application.api.utils.metadata_utils
import
marshall_table_full
from
unittest.mock
import
patch
,
Mock
from
amundsen_application.api.utils.metadata_utils
import
_update_prog_descriptions
,
_sort_prog_descriptions
from
amundsen_application
import
create_app
local_app
=
create_app
(
'amundsen_application.config.TestConfig'
,
'tests/templates'
)
class
MetadataUtil
sTest
(
unittest
.
TestCase
):
class
ProgrammaticDescription
sTest
(
unittest
.
TestCase
):
def
setUp
(
self
)
->
None
:
self
.
input_data
=
{
'cluster'
:
'test_cluster'
,
'columns'
:
[
{
'name'
:
'column_1'
,
'description'
:
'This is a test'
,
'col_type'
:
'bigint'
,
'sort_order'
:
0
,
'stats'
:
[
{
'stat_type'
:
'count'
,
'stat_val'
:
'100'
,
'start_epoch'
:
1538352000
,
'end_epoch'
:
1538352000
},
{
'stat_type'
:
'count_null'
,
'stat_val'
:
'0'
,
'start_epoch'
:
1538352000
,
'end_epoch'
:
1538352000
}
]
}
],
'database'
:
'test_db'
,
'is_view'
:
False
,
'key'
:
'test_db://test_cluster.test_schema/test_table'
,
'owners'
:
[],
'schema'
:
'test_schema'
,
'name'
:
'test_table'
,
'table_description'
:
'This is a test'
,
'tags'
:
[],
'table_readers'
:
[
{
'user'
:
{
'email'
:
'test@test.com'
,
'first_name'
:
None
,
'last_name'
:
None
},
'read_count'
:
100
}
],
'watermarks'
:
[
{
'watermark_type'
:
'low_watermark'
,
'partition_key'
:
'ds'
,
'partition_value'
:
''
,
'create_time'
:
''
},
{
'watermark_type'
:
'high_watermark'
,
'partition_key'
:
'ds'
,
'partition_value'
:
''
,
'create_time'
:
''
}
],
'table_writer'
:
{
'application_url'
:
'https://test-test.test.test'
,
'name'
:
'test_name'
,
'id'
:
'test_id'
,
'description'
:
'This is a test'
},
'programmatic_descriptions'
:
[
pass
@
patch
(
'amundsen_application.api.utils.metadata_utils._sort_prog_descriptions'
)
def
test_update_prog_descriptions
(
self
,
sort_mock
)
->
None
:
with
local_app
.
app_context
():
test_desc
=
[
{
'source'
:
'c_1'
,
'text'
:
'description c'
},
{
'source'
:
'a_1'
,
'text'
:
'description a'
},
{
'source'
:
'b_1'
,
'text'
:
'description b'
}
]
}
# Pretend config exists
local_app
.
config
[
'PROGRAMMATIC_DISPLAY'
]
=
Mock
()
# Mock the effects of the sort method
sort_mock
.
side_effect
=
[
1
,
0
,
1
]
# Expected order based on mocked side effect
expected_programmatic_desc
=
[
{
'source'
:
'a_1'
,
'text'
:
'description a'
},
{
'source'
:
'c_1'
,
'text'
:
'description c'
},
{
'source'
:
'b_1'
,
'text'
:
'description b'
}
]
_update_prog_descriptions
(
test_desc
)
self
.
assertEqual
(
test_desc
,
expected_programmatic_desc
)
self
.
expected_data
=
{
'badges'
:
[],
'cluster'
:
'test_cluster'
,
'columns'
:
[{
'col_type'
:
'bigint'
,
'description'
:
'This is a test'
,
'name'
:
'column_1'
,
'sort_order'
:
0
,
'stats'
:
[{
'end_epoch'
:
1538352000
,
'start_epoch'
:
1538352000
,
'stat_type'
:
'count'
,
'stat_val'
:
'100'
},
{
'end_epoch'
:
1538352000
,
'start_epoch'
:
1538352000
,
'stat_type'
:
'count_null'
,
'stat_val'
:
'0'
}]}],
'database'
:
'test_db'
,
'description'
:
None
,
'is_editable'
:
True
,
'is_view'
:
False
,
'key'
:
'test_db://test_cluster.test_schema/test_table'
,
'last_updated_timestamp'
:
None
,
'name'
:
'test_table'
,
'owners'
:
[],
'partition'
:
{
'is_partitioned'
:
True
,
'key'
:
'ds'
,
'value'
:
''
},
'programmatic_descriptions'
:
[{
'source'
:
'a_1'
,
'text'
:
'description a'
},
{
'source'
:
'c_1'
,
'text'
:
'description c'
},
{
'source'
:
'b_1'
,
'text'
:
'description b'
}],
'schema'
:
'test_schema'
,
'source'
:
None
,
'table_readers'
:
[{
'read_count'
:
100
,
'user'
:
{
'display_name'
:
'test@test.com'
,
'email'
:
'test@test.com'
,
'employee_type'
:
None
,
'first_name'
:
None
,
'full_name'
:
None
,
'github_username'
:
None
,
'is_active'
:
True
,
'last_name'
:
None
,
'manager_email'
:
None
,
'manager_fullname'
:
None
,
'profile_url'
:
''
,
'role_name'
:
None
,
'slack_id'
:
None
,
'team_name'
:
None
,
'user_id'
:
'test@test.com'
}}],
'table_writer'
:
{
'application_url'
:
'https://test-test.test.test'
,
'description'
:
'This is a test'
,
'id'
:
'test_id'
,
'kind'
:
None
,
'name'
:
'test_name'
},
'tags'
:
[],
'watermarks'
:
[{
'create_time'
:
''
,
'partition_key'
:
'ds'
,
'partition_value'
:
''
,
'watermark_type'
:
'low_watermark'
},
{
'create_time'
:
''
,
'partition_key'
:
'ds'
,
'partition_value'
:
''
,
'watermark_type'
:
'high_watermark'
}]}
def
test_sort_prog_descriptions_returns_value_from_config
(
self
)
->
None
:
"""
Verify the method will return the display order from the programmtic description
configuration if it exists for the given source
:return:
"""
with
local_app
.
app_context
():
mock_order
=
1
mock_config
=
{
"c_1"
:
{
"display_order"
:
mock_order
}
}
in_config_value
=
{
'source'
:
'c_1'
,
'text'
:
'I am a test'
}
self
.
assertEqual
(
_sort_prog_descriptions
(
mock_config
,
in_config_value
),
mock_order
)
def
test_marshal_table_full
(
self
)
->
None
:
def
test_sort_prog_descriptions_returns_default_value
(
self
)
->
None
:
"""
Verify the method will return the expected default value if programmtic decsription
source is not included in teh configuration
:return:
"""
with
local_app
.
app_context
():
actual_result
=
marshall_table_full
(
self
.
input_data
)
self
.
assertEqual
(
actual_result
,
self
.
expected_data
)
mock_config
=
{
"c_1"
:
{
"display_order"
:
0
}
}
not_in_config_value
=
{
'source'
:
'test'
,
'text'
:
'I am a test'
}
self
.
assertEqual
(
_sort_prog_descriptions
(
mock_config
,
not_in_config_value
),
len
(
mock_config
))
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