11# flake8: noqa: E501
22import json
33
4+ from osw .utils .oold import escape_double_quotes
45from osw .utils .templates import eval_handlebars_template
56
67
@@ -49,7 +50,7 @@ def test_category_template():
4950 "metaclass" : ["Category:OSW725a3cf5458f4daea86615fcbd0029f8" ],
5051 "description" : [
5152 {
52- "text" : " Represents the set of all individuals. In the DL literature this is often called the top concept." ,
53+ "text" : ' Represents the set of all " individuals" . In the DL literature this is often called the top concept.' ,
5354 "lang" : "en" ,
5455 }
5556 ],
@@ -72,9 +73,9 @@ def test_category_template():
7273 "title*": {
7374 "en": "OwlThing"
7475 },
75- "description": "Represents the set of all individuals. In the DL literature this is often called the top concept.",
76+ "description": "Represents the set of all \\ " individuals\\ " . In the DL literature this is often called the top concept.",
7677 "description*": {
77- "en": "Represents the set of all individuals. In the DL literature this is often called the top concept."
78+ "en": "Represents the set of all \\ " individuals\\ " . In the DL literature this is often called the top concept."
7879 },
7980 "required": [
8081 "type"
@@ -92,7 +93,7 @@ def test_category_template():
9293 output = json .loads (
9394 eval_handlebars_template (
9495 template ,
95- data ,
96+ escape_double_quotes ( data ) ,
9697 {"_page_title" : "Category:OSW379d5a1589c74c82bc0de47938264d00" },
9798 )
9899 )
@@ -326,4 +327,41 @@ def test_helper_join():
326327 assert output == expected
327328
328329
329- test_helper_join ()
330+ def test_raw_block ():
331+ template = """
332+ {
333+ "unit": {
334+ "format": "autocomplete",
335+ "options": {
336+ "autocomplete": {
337+ "query": "[[-HasUnit::{{{quantity}}}]][[HasSymbol::like:*\{{_user_input}}*]]OR[[-HasPrefixUnit.-HasUnit::{{{quantity}}}]][[HasSymbol::like:*\{{_user_input}}*]]|?HasSymbol=label"
338+ }
339+ }
340+ }
341+ }"""
342+
343+ data = {
344+ "quantity" : "Item:OSW1bd92826da6f5c53982ed6ea45bc1b9b" ,
345+ }
346+
347+ expected = """
348+ {
349+ "unit": {
350+ "format": "autocomplete",
351+ "options": {
352+ "autocomplete": {
353+ "query": "[[-HasUnit::Item:OSW1bd92826da6f5c53982ed6ea45bc1b9b]][[HasSymbol::like:*{{_user_input}}*]]OR[[-HasPrefixUnit.-HasUnit::Item:OSW1bd92826da6f5c53982ed6ea45bc1b9b]][[HasSymbol::like:*{{_user_input}}*]]|?HasSymbol=label"
354+ }
355+ }
356+ }
357+ }
358+ """
359+ res = eval_handlebars_template (
360+ template ,
361+ data ,
362+ {"_page_title" : "Category:OSW379d5a1589c74c82bc0de47938264d00" },
363+ )
364+
365+ output = json .loads (res )
366+
367+ assert output == json .loads (expected )
0 commit comments