code: def validate_num_assertions(self):
          
          encrypted_assertion_nodes = OneLogin_Saml2_XML.query(self.document, '//saml:EncryptedAssertion')
          assertion_nodes = OneLogin_Saml2_XML.query(self.document, '//saml:Assertion')
  
          valid = len(encrypted_assertion_nodes) + len(assertion_nodes) == 1
  
          if (self.encrypted):
              assertion_nodes = OneLogin_Saml2_XML.query(self.decrypted_document, '//saml:Assertion')
              valid = valid and len(assertion_nodes) == 1
  
          return valid
docs: Verifies that the document only contains a single Assertion (encrypted or not)
  
          :returns: True if only 1 assertion encrypted or not
          :rtype: bool