コード例 #1
0
    def testGetSessionIdentifier(self):
        """Tests the GetSessionIdentifier function."""
        attribute_container = interface.AttributeContainer()

        session_identifier = attribute_container.GetSessionIdentifier()

        self.assertIsNone(session_identifier)
コード例 #2
0
    def testGetAttributes(self):
        """Tests the GetAttributes function."""
        attribute_container = interface.AttributeContainer()
        attribute_container._protected_attribute = 'protected'
        attribute_container.attribute_name = 'attribute_name'
        attribute_container.attribute_value = 'attribute_value'

        expected_attributes = [('attribute_name', 'attribute_name'),
                               ('attribute_value', 'attribute_value')]

        attributes = sorted(attribute_container.GetAttributes())

        self.assertEqual(attributes, expected_attributes)

        attribute_container._SERIALIZABLE_PROTECTED_ATTRIBUTES = [
            '_protected_attribute'
        ]

        expected_attributes = [('_protected_attribute', 'protected'),
                               ('attribute_name', 'attribute_name'),
                               ('attribute_value', 'attribute_value')]

        attributes = sorted(attribute_container.GetAttributes())

        self.assertEqual(attributes, expected_attributes)
コード例 #3
0
    def testGetAttributeValuesString(self):
        """Tests the GetAttributeValuesString function."""
        attribute_container = interface.AttributeContainer()
        attribute_container._protected_attribute = 'protected'
        attribute_container.attribute_name = 'attribute_name'
        attribute_container.attribute_value = 'attribute_value'

        attribute_values_string1 = attribute_container.GetAttributeValuesString(
        )

        attribute_container.attribute_value = 'changes'

        attribute_values_string2 = attribute_container.GetAttributeValuesString(
        )

        self.assertNotEqual(attribute_values_string1, attribute_values_string2)

        attribute_container.attribute_value = 'attribute_value'

        attribute_container._SERIALIZABLE_PROTECTED_ATTRIBUTES = [
            '_protected_attribute'
        ]

        attribute_values_string2 = attribute_container.GetAttributeValuesString(
        )

        self.assertNotEqual(attribute_values_string1, attribute_values_string2)
コード例 #4
0
    def testGetAttributeNames(self):
        """Tests the GetAttributeNames function."""
        attribute_container = interface.AttributeContainer()
        attribute_container.attribute_name = u'attribute_name'
        attribute_container.attribute_value = u'attribute_value'

        expected_attribute_names = [u'attribute_name', u'attribute_value']

        attribute_names = sorted(attribute_container.GetAttributeNames())

        self.assertEqual(attribute_names, expected_attribute_names)
コード例 #5
0
  def testGetAttributeValuesString(self):
    """Tests the GetAttributeValuesString function."""
    attribute_container = interface.AttributeContainer()
    attribute_container.attribute_name = 'attribute_name'
    attribute_container.attribute_value = 'attribute_value'

    attribute_values_string1 = attribute_container.GetAttributeValuesString()

    attribute_container.attribute_value = 'changes'

    attribute_values_string2 = attribute_container.GetAttributeValuesString()

    self.assertNotEqual(attribute_values_string1, attribute_values_string2)
コード例 #6
0
  def testGetAttributeValueHash(self):
    """Tests the GetAttributeValuesHash function."""
    attribute_container = interface.AttributeContainer()
    attribute_container.attribute_name = 'attribute_name'
    attribute_container.attribute_value = 'attribute_value'

    attribute_values_hash1 = attribute_container.GetAttributeValuesHash()

    attribute_container.attribute_value = 'changes'

    attribute_values_hash2 = attribute_container.GetAttributeValuesHash()

    self.assertNotEqual(attribute_values_hash1, attribute_values_hash2)
コード例 #7
0
  def testCopyToDict(self):
    """Tests the CopyToDict function."""
    attribute_container = interface.AttributeContainer()
    attribute_container.attribute_name = 'attribute_name'
    attribute_container.attribute_value = 'attribute_value'

    expected_dict = {
        'attribute_name': 'attribute_name',
        'attribute_value': 'attribute_value'}

    test_dict = attribute_container.CopyToDict()

    self.assertEqual(test_dict, expected_dict)
コード例 #8
0
    def testMatchesExpression(self):
        """Tests the MatchesExpression function."""
        attribute_container = interface.AttributeContainer()
        attribute_container.name = 'value'

        result = attribute_container.MatchesExpression('name == "value"')
        self.assertTrue(result)

        result = attribute_container.MatchesExpression('name == "bogus"')
        self.assertFalse(result)

        result = attribute_container.MatchesExpression('bogus')
        self.assertFalse(result)
コード例 #9
0
    def testSetSessionIdentifier(self):
        """Tests the SetSessionIdentifier function."""
        attribute_container = interface.AttributeContainer()

        attribute_container.SetSessionIdentifier(None)