mirror of
https://github.com/google/nomulus.git
synced 2025-05-13 16:07:15 +02:00
Improve ICANN reporting golden query test
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=159570806
This commit is contained in:
parent
e94ba8d2af
commit
d05151b026
2 changed files with 17 additions and 4 deletions
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
"""Tests for google.registry.reporting.icann_report_query_builder."""
|
"""Tests for google.registry.reporting.icann_report_query_builder."""
|
||||||
|
|
||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
@ -35,10 +36,20 @@ class IcannReportQueryBuilderTest(unittest.TestCase):
|
||||||
golden_activity_query_path = os.path.join(self.testdata_path,
|
golden_activity_query_path = os.path.join(self.testdata_path,
|
||||||
'golden_activity_query.sql')
|
'golden_activity_query.sql')
|
||||||
with open(golden_activity_query_path, 'r') as golden_activity_query:
|
with open(golden_activity_query_path, 'r') as golden_activity_query:
|
||||||
self.assertMultiLineEqual(golden_activity_query.read(),
|
golden_file_contents = golden_activity_query.read()
|
||||||
query_builder.BuildActivityReportQuery(
|
# Remove golden file copyright header by stripping until END OF HEADER.
|
||||||
month='2016-06',
|
golden_file_sql = golden_file_contents.split('-- END OF HEADER\n')[1]
|
||||||
registrar_count=None))
|
actual_sql = query_builder.BuildActivityReportQuery(
|
||||||
|
month='2016-06', registrar_count=None)
|
||||||
|
try:
|
||||||
|
self.assertMultiLineEqual(golden_file_sql, actual_sql)
|
||||||
|
except AssertionError as e:
|
||||||
|
# Print the actual SQL generated so that it's easy to copy-paste into
|
||||||
|
# the golden file when updating the query.
|
||||||
|
sep = '=' * 50 + '\n'
|
||||||
|
logging.warning(
|
||||||
|
'Generated activity query SQL:\n' + sep + actual_sql + sep)
|
||||||
|
raise e
|
||||||
|
|
||||||
def testStringTrailingWhitespaceFromLines(self):
|
def testStringTrailingWhitespaceFromLines(self):
|
||||||
def do_test(expected, original):
|
def do_test(expected, original):
|
||||||
|
|
|
@ -12,6 +12,8 @@
|
||||||
-- See the License for the specific language governing permissions and
|
-- See the License for the specific language governing permissions and
|
||||||
-- limitations under the License.
|
-- limitations under the License.
|
||||||
|
|
||||||
|
-- END OF HEADER
|
||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
Tld.tld AS tld,
|
Tld.tld AS tld,
|
||||||
SUM(IF(metricName = 'operational-registrars', count, 0)) AS operational_registrars,
|
SUM(IF(metricName = 'operational-registrars', count, 0)) AS operational_registrars,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue