Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
olapy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
olapy
Commits
6f9df817
Commit
6f9df817
authored
Jul 17, 2017
by
mouadh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add tests
parent
05aa2ddb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
83 additions
and
38 deletions
+83
-38
tests/test_parsing_queries.py
tests/test_parsing_queries.py
+83
-38
No files found.
tests/test_parsing_queries.py
View file @
6f9df817
...
...
@@ -22,44 +22,17 @@ query4 = """SELECT
non empty {[Geography].[Geo].[Country].members} ON ROWS
FROM [sales]"""
query5
=
"""select
{[Geography].[Economy].[Country]} on 0,
non empty {[Geography].[Geo].[Country].members} on 1
FROM [sales]"""
query6
=
"""select
{[Geography].[Economy].[Partnership]} on 0,
{[Product].[Prod].[Company]} on 1
FROM [sales]"""
query7
=
"""select
{[Geography].[Economy].[Partnership].[EU]} on 0,
{[Product].[Prod].[Company].[Crazy Development]} on 1
FROM [sales]"""
query8
=
"""select
query5
=
"""SELECT
{[Geography].[Economy].[Partnership].[EU],
[Geography].[Economy].[Partnership].[None],
[Geography].[Economy].[Partnership].[NAFTA]}
on 0
,
[Geography].[Economy].[Partnership].[NAFTA]}
ON COLUMNS
,
{[Product].[Prod].[Company].[Crazy Development],
[Product].[Prod].[Company].[Company_test],
[Product].[Prod].[Company].[test_Development]}
on 1
[Product].[Prod].[Company].[test_Development]}
ON ROWS
FROM [sales]"""
query9
=
"""select
{[Geography].[Economy].[Partnership].[EU],
[Geography].[Economy].[Partnership].[None]} on 0
FROM [sales]"""
query10
=
"""select
{[Geography].[Geo].[Country].[France],
[Geography].[Geo].[Country].[Spain]} on 0,
non empty {[Measures].[Amount]} on 1
FROM [sales]"""
where
=
"WHERE [Time].[Calendar].[Day].[May 12,2010]"
query11
=
"""
# GENERATED BY EXCEL
query6
=
"""
SELECT NON EMPTY Hierarchize(AddCalculatedMembers(DrilldownMember({{DrilldownMember({{DrilldownMember({{
[Time].[Time].[Year].Members}}, {
[Time].[Time].[Year].[2010]})}}, {
...
...
@@ -70,12 +43,7 @@ query11 = """
CELL PROPERTIES VALUE, FORMAT_STRING, LANGUAGE, BACK_COLOR, FORE_COLOR, FONT_FLAGS
"""
query12
=
"""SELECT NON EMPTY Hierarchize(AddCalculatedMembers({
[Geography].[Geography].[Continent].Members}))
DIMENSION PROPERTIES PARENT_UNIQUE_NAME,HIERARCHY_UNIQUE_NAME ON COLUMNS
FROM [sales]
WHERE ([Measures].[Amount])
CELL PROPERTIES VALUE, FORMAT_STRING, LANGUAGE, BACK_COLOR, FORE_COLOR, FONT_FLAGS"""
where
=
"WHERE [Time].[Calendar].[Day].[May 12,2010]"
executer
=
MdxEngine
(
CUBE
)
...
...
@@ -144,3 +112,80 @@ def test_parsing_query4():
assert
query_parts
[
'rows'
]
==
[[
'Geography'
,
'Geo'
,
'Country'
]]
assert
query_parts
[
'where'
]
==
[[
'Time'
,
'Calendar'
,
'Day'
,
'May 12,2010'
]]
assert
query_parts
[
'columns'
]
==
[[
'Geography'
,
'Economy'
,
'Partnership'
]]
def
test_parsing_query5
():
query_parts
=
executer
.
decorticate_query
(
query5
)
assert
query_parts
[
'all'
]
==
[[
'Geography'
,
'Economy'
,
'Partnership'
,
'EU'
],
[
'Geography'
,
'Economy'
,
'Partnership'
,
'None'
],
[
'Geography'
,
'Economy'
,
'Partnership'
,
'NAFTA'
],
[
'Product'
,
'Prod'
,
'Company'
,
'Crazy Development'
],
[
'Product'
,
'Prod'
,
'Company'
,
'Company_test'
],
[
'Product'
,
'Prod'
,
'Company'
,
'test_Development'
]]
assert
query_parts
[
'rows'
]
==
[[
'Product'
,
'Prod'
,
'Company'
,
'Crazy Development'
],
[
'Product'
,
'Prod'
,
'Company'
,
'Company_test'
],
[
'Product'
,
'Prod'
,
'Company'
,
'test_Development'
]]
assert
query_parts
[
'where'
]
==
[]
assert
query_parts
[
'columns'
]
==
[[
'Geography'
,
'Economy'
,
'Partnership'
,
'EU'
],
[
'Geography'
,
'Economy'
,
'Partnership'
,
'None'
],
[
'Geography'
,
'Economy'
,
'Partnership'
,
'NAFTA'
]]
query_parts
=
executer
.
decorticate_query
(
query5
+
'
\
n
'
+
where
)
assert
query_parts
[
'all'
]
==
[[
'Geography'
,
'Economy'
,
'Partnership'
,
'EU'
],
[
'Geography'
,
'Economy'
,
'Partnership'
,
'None'
],
[
'Geography'
,
'Economy'
,
'Partnership'
,
'NAFTA'
],
[
'Product'
,
'Prod'
,
'Company'
,
'Crazy Development'
],
[
'Product'
,
'Prod'
,
'Company'
,
'Company_test'
],
[
'Product'
,
'Prod'
,
'Company'
,
'test_Development'
],
[
'Time'
,
'Calendar'
,
'Day'
,
'May 12,2010'
]]
assert
query_parts
[
'rows'
]
==
[[
'Product'
,
'Prod'
,
'Company'
,
'Crazy Development'
],
[
'Product'
,
'Prod'
,
'Company'
,
'Company_test'
],
[
'Product'
,
'Prod'
,
'Company'
,
'test_Development'
]]
assert
query_parts
[
'where'
]
==
[[
'Time'
,
'Calendar'
,
'Day'
,
'May 12,2010'
]]
assert
query_parts
[
'columns'
]
==
[[
'Geography'
,
'Economy'
,
'Partnership'
,
'EU'
],
[
'Geography'
,
'Economy'
,
'Partnership'
,
'None'
],
[
'Geography'
,
'Economy'
,
'Partnership'
,
'NAFTA'
]]
def
test_parsing_query6
():
# query generated by excel
query_parts
=
executer
.
decorticate_query
(
query6
)
assert
query_parts
[
'all'
]
==
[[
'Time'
,
'Time'
,
'Year'
],
[
'Time'
,
'Time'
,
'Year'
,
'2010'
],
[
'Time'
,
'Time'
,
'Quarter'
,
'2010'
,
'Q2 2010'
],
[
'Time'
,
'Time'
,
'Month'
,
'2010'
,
'Q2 2010'
,
'May 2010'
],
[
'Measures'
,
'Amount'
]]
assert
query_parts
[
'rows'
]
==
[]
assert
query_parts
[
'where'
]
==
[[
'Measures'
,
'Amount'
]]
assert
query_parts
[
'columns'
]
==
[[
'Time'
,
'Time'
,
'Year'
],
[
'Time'
,
'Time'
,
'Year'
,
'2010'
],
[
'Time'
,
'Time'
,
'Quarter'
,
'2010'
,
'Q2 2010'
],
[
'Time'
,
'Time'
,
'Month'
,
'2010'
,
'Q2 2010'
,
'May 2010'
]]
query_parts
=
executer
.
decorticate_query
(
query6
+
'
\
n
'
+
where
)
assert
query_parts
[
'all'
]
==
[[
'Time'
,
'Time'
,
'Year'
],
[
'Time'
,
'Time'
,
'Year'
,
'2010'
],
[
'Time'
,
'Time'
,
'Quarter'
,
'2010'
,
'Q2 2010'
],
[
'Time'
,
'Time'
,
'Month'
,
'2010'
,
'Q2 2010'
,
'May 2010'
],
[
'Measures'
,
'Amount'
],
[
'Time'
,
'Calendar'
,
'Day'
,
'May 12,2010'
]]
assert
query_parts
[
'rows'
]
==
[]
assert
query_parts
[
'where'
]
==
[[
'Measures'
,
'Amount'
],
[
'Time'
,
'Calendar'
,
'Day'
,
'May 12,2010'
]]
assert
query_parts
[
'columns'
]
==
[[
'Time'
,
'Time'
,
'Year'
],
[
'Time'
,
'Time'
,
'Year'
,
'2010'
],
[
'Time'
,
'Time'
,
'Quarter'
,
'2010'
,
'Q2 2010'
],
[
'Time'
,
'Time'
,
'Month'
,
'2010'
,
'Q2 2010'
,
'May 2010'
]]
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