def build(self, builder): """ Build XML by appending to builder """ params = dict(ItemOID=self.itemoid) if self.transaction_type is not None: params["TransactionType"] = self.transaction_type if self.value in [None, ""]: params["IsNull"] = "Yes" else: params["Value"] = str(self.value) if self.specify_value is not None: params["mdsol:SpecifyValue"] = self.specify_value if self.lock is not None: params["mdsol:Lock"] = bool_to_yes_no(self.lock) if self.freeze is not None: params["mdsol:Freeze"] = bool_to_yes_no(self.freeze) if self.verify is not None: params["mdsol:Verify"] = bool_to_yes_no(self.verify) # mixins self.mixin() self.mixin_params(params) builder.start("ItemData", params) if self.audit_record is not None: self.audit_record.build(builder) # Measurement unit ref must be after audit record or RWS complains if self.measurement_unit_ref is not None: self.measurement_unit_ref.build(builder) for query in self.queries: # type: MdsolQuery query.build(builder) for deviation in self.deviations: # type: MdsolProtocolDeviation deviation.build(builder) for annotation in self.annotations: # type: Annotation annotation.build(builder) builder.end("ItemData")
def build(self, builder): """ Build XML by appending to builder """ params = {} if self.value is not None: params["Value"] = str(self.value) if self.query_repeat_key is not None: params["QueryRepeatKey"] = str(self.query_repeat_key) if self.recipient is not None: params["Recipient"] = str(self.recipient) if self.status is not None: params["Status"] = self.status.value if self.requires_response is not None: params["RequiresResponse"] = bool_to_yes_no(self.requires_response) # When closing a query if self.response is not None: params["Response"] = str(self.response) # When re-opening a query if self.preceding_query_repeat_key is not None: params["PrecedingQueryRepeatKey"] = str( self.preceding_query_repeat_key) builder.start("mdsol:Query", params) builder.end("mdsol:Query")
def build(self, builder): """Build XML by appending to builder""" params = {} if self.edit_point is not None: params["EditPoint"] = self.edit_point if self.used_imputation_method is not None: params["UsedImputationMethod"] = bool_to_yes_no( self.used_imputation_method) if self.audit_id is not None: params["ID"] = str(self.audit_id) if self.include_file_oid is not None: params["mdsol:IncludeFileOID"] = bool_to_yes_no( self.include_file_oid) builder.start("AuditRecord", params) if self.user_ref is None: raise ValueError("User Reference not set.") self.user_ref.build(builder) if self.location_ref is None: raise ValueError("Location Reference not set.") self.location_ref.build(builder) if self.date_time_stamp is None: raise ValueError("DateTime not set.") self.date_time_stamp.build(builder) # Optional if self.source_id: self.source_id.build(builder) # Optional if self.reason_for_change is not None: self.reason_for_change.build(builder) builder.end("AuditRecord")
def test_false_to_FALSE(self): """FALSE returned from false""" self.assertEqual('No', bool_to_yes_no(False))
def test_true_to_TRUE(self): """TRUE returned from true""" self.assertEqual('Yes', bool_to_yes_no(True))