Commit 6f9df817 authored by mouadh's avatar mouadh

add tests

parent 05aa2ddb
......@@ -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']]
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment