report/category-barchart: fix unit test to work with gnc-monetary

The unit test for category-barchart did not initialize html stylesheets.
Without any stylesheets available, the renderer defaults to a
trivial renderer. This works fine if the table in the report is
populated by doubles. However, now it is populated by gnc-monetary
and they need a stylesheet to be properly formatted.

This commit makes sure to initialize the html stylesheet code in
the unit test and adapts the parsing code to the new formatting.
This commit is contained in:
Jose Marino
2017-10-18 14:44:54 -06:00
parent 3913c528f1
commit f4acb6c000

View File

@@ -32,6 +32,7 @@
(use-modules (gnucash app-utils))
(use-modules (gnucash engine))
(use-modules (sw_engine))
(use-modules (gnucash report stylesheets))
(use-modules (gnucash report report-system collectors))
(use-modules (gnucash engine test test-extras))
@@ -114,8 +115,8 @@
(let* ((result (gnc:html-document-render doc #f))
(tbl (stream->list
(pattern-streamer "<tr>"
(list (list "<string> ([0-9][0-9])/([0-9][0-9])/([0-9][0-9])</td>" 1 2 3)
(list "<number> ([^<]*)</td>" 1))
(list (list "<td>([0-9][0-9])/([0-9][0-9])/([0-9][0-9])</td>" 1 2 3)
(list "<td class=\"number-cell\">[^0-9]*([^<]*)</td>" 1))
result))))
(every (lambda (date value-list)
(let ((day (second date))
@@ -172,12 +173,12 @@
(columns (columns-from-report-document html-document))
(tbl (stream->list
(pattern-streamer "<tr>"
(list (list "<string> ([0-9][0-9])/([0-9][0-9])/([0-9][0-9])</td>" 1 2 3)
(list "<number> ([^<]*)</td>" 1)
(list "<number> ([^<]*)</td>" 1)
(list "<number> ([^<]*)</td>" 1)
(list "<number> ([^<]*)</td>" 1)
(list "<number> ([^<]*)</td>" 1))
(list (list "<td>([0-9][0-9])/([0-9][0-9])/([0-9][0-9])</td>" 1 2 3)
(list "<td class=\"number-cell\">[^0-9]*([^<]*)</td>" 1)
(list "<td class=\"number-cell\">[^0-9]*([^<]*)</td>" 1)
(list "<td class=\"number-cell\">[^0-9]*([^<]*)</td>" 1)
(list "<td class=\"number-cell\">[^0-9]*([^<]*)</td>" 1)
(list "<td class=\"number-cell\">[^0-9]*([^<]*)</td>" 1))
html-document))))
;(format #t "~a" html-document)
(and (= 6 (length columns))
@@ -188,7 +189,7 @@
(define (columns-from-report-document doc)
(let ((columns (stream->list (pattern-streamer "<th>"
(list (list "<string> ([^<]*)</" 1))
(list (list "<th>([^<]*)</" 1))
doc))))
(map caar columns)))
@@ -231,8 +232,8 @@
(columns (columns-from-report-document html-document))
(tbl (stream->list
(pattern-streamer "<tr>"
(list (list "<string> ([0-9][0-9])/([0-9][0-9])/([0-9][0-9])</td>" 1 2 3)
(list "<number> ([^<]*)</td>" 1))
(list (list "<td>([0-9][0-9])/([0-9][0-9])/([0-9][0-9])</td>" 1 2 3)
(list "<td class=\"number-cell\">[^0-9]*([^<]*)</td>" 1))
html-document)))
(row-count (tbl-row-count tbl)))
(and (member "account-1" columns)