From 09c3f015d55f591d548c509e89271c0dbcc07c51 Mon Sep 17 00:00:00 2001
From: Rolf Niepraschk <Rolf.Niepraschk@ptb.de>
Date: Fri, 11 Mar 2022 08:10:40 +0100
Subject: [PATCH] more defined tests

---
 templates/xml/calibration_laboratory.xml | 14 ++++++++++++--
 templates/xml/core_data.xml              |  2 +-
 templates/xml/influence_conditions.xml   |  2 +-
 templates/xml/responsible_persons.xml    |  6 ++++--
 templates/xml/results.xml                |  2 +-
 templates/xml/statements.xml             |  2 +-
 templates/xml/used_software.xml          |  2 ++
 7 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/templates/xml/calibration_laboratory.xml b/templates/xml/calibration_laboratory.xml
index 6c1d5fb..8186a55 100644
--- a/templates/xml/calibration_laboratory.xml
+++ b/templates/xml/calibration_laboratory.xml
@@ -7,8 +7,10 @@
         <![CDATA[{%- for j in i.content %}{{j|safe}}{% endfor -%}]]>
       </dcc:content>
       {% endfor -%}
-    </dcc:name>  
+    </dcc:name>
+    {%- if x['eMail'] is defined %}
     <dcc:eMail>{{x.eMail}}</dcc:eMail>
+    {% endif -%}
     <dcc:location>
       <dcc:further>
         {%- for i in x.location.further %}
@@ -17,13 +19,21 @@
          </dcc:content>
         {% endfor -%}
       </dcc:further>
+      {%- if x.location.street is defined %}
       <dcc:street>{{x.location.street}}</dcc:street>
-      {%- if x.location.streetNo %}
+      {% endif -%}
+      {%- if x.location.streetNo is defined %}
       <dcc:streetNo>{{x.location.streetNo}}</dcc:streetNo>
       {% endif -%}
+      {%- if x.location.postCode is defined %}
       <dcc:postCode>{{x.location.postCode}}</dcc:postCode>
+      {% endif -%}
+      {%- if x.location.city is defined %}
       <dcc:city>{{x.location.city}}</dcc:city>
+      {% endif -%}
+      {%- if x.location.countryCode is defined %}
       <dcc:countryCode>{{x.location.countryCode}}</dcc:countryCode>
+      {% endif -%}      
     </dcc:location>
   </dcc:contact>
 </dcc:calibrationLaboratory>
diff --git a/templates/xml/core_data.xml b/templates/xml/core_data.xml
index 1789c05..2e7bf26 100644
--- a/templates/xml/core_data.xml
+++ b/templates/xml/core_data.xml
@@ -27,7 +27,7 @@
         </dcc:identification>
         {% endfor -%}
       </dcc:identifications>
-      {%- if x.receiptDate %}         
+      {%- if x['receiptDate'] is defined %}        
       <dcc:receiptDate> 
         {{x.receiptDate}}
       </dcc:receiptDate>
diff --git a/templates/xml/influence_conditions.xml b/templates/xml/influence_conditions.xml
index b279c4a..9167206 100644
--- a/templates/xml/influence_conditions.xml
+++ b/templates/xml/influence_conditions.xml
@@ -27,7 +27,7 @@
         <si:real>
           <si:value>{{v.real.value}}</si:value>
           <si:unit>{{v.real.unit}}</si:unit>
-          {%- if v.real.expandedUnc %}
+          {%- if v.real['expandedUnc'] is defined %}
           <si:expandedUnc>
             <si:uncertainty>
               {{v.real.expandedUnc.uncertainty}}
diff --git a/templates/xml/responsible_persons.xml b/templates/xml/responsible_persons.xml
index f62e8fc..f806ec0 100644
--- a/templates/xml/responsible_persons.xml
+++ b/templates/xml/responsible_persons.xml
@@ -8,10 +8,12 @@
           <![CDATA[{%- for k in j.content %}{{k|safe}}{% endfor -%}]]>
         </dcc:content>
         {% endfor -%}
-      </dcc:name>      
+      </dcc:name>  
+      {%- if i.person['eMail'] is defined %}    
       <dcc:eMail>{{i.person.eMail}}</dcc:eMail>
+      {% endif -%}
     </dcc:person>
-    {%- if i.mainSigner %}
+     {%- if i['mainSigner'] is defined %}
     <dcc:mainSigner>{{i.mainSigner|lower}}</dcc:mainSigner>
     {% endif -%}
   </dcc:respPerson>            
diff --git a/templates/xml/results.xml b/templates/xml/results.xml
index 105bbcc..a2d905c 100644
--- a/templates/xml/results.xml
+++ b/templates/xml/results.xml
@@ -23,7 +23,7 @@
           <si:real>
             <si:value>{{k.real.value}}</si:value>
             <si:unit>{{k.real.unit}}</si:unit>
-            {%- if k.real.expandedUnc %}
+            {%- if k.real['expandedUnc'] is defined %}
             <si:expandedUnc>
               {# TODO: Alle Komponenten immer vorhanden? #} 
               <si:uncertainty>
diff --git a/templates/xml/statements.xml b/templates/xml/statements.xml
index 27caefd..9475804 100644
--- a/templates/xml/statements.xml
+++ b/templates/xml/statements.xml
@@ -32,7 +32,7 @@
     <dcc:date>{{i.date}}</dcc:date> 
     {% endif -%}  
     {% if i['respAuthority'] is defined %}
-    <dcc:respAuthority>               {#  TODO: auch bei customer übernehmen. #}
+    <dcc:respAuthority>
       {% set x1 = i['respAuthority'] %}
       {%- if x1['name'] is defined %}
       <dcc:name>   
diff --git a/templates/xml/used_software.xml b/templates/xml/used_software.xml
index 89733e6..111daef 100644
--- a/templates/xml/used_software.xml
+++ b/templates/xml/used_software.xml
@@ -8,7 +8,9 @@
       </dcc:content>
       {% endfor -%}
     </dcc:name>
+    {%- if i['release'] is defined %}
     <dcc:release>{{i.release}}</dcc:release>
+    {% endif -%}
   </dcc:software>
   {% endfor -%} 
 </dcc:dccSoftware>
-- 
GitLab