def test_not_equal_on_equal(self):
        """
        Test that the inequality operator returns False when comparing
        two GetAttributeList request payloads with the same internal data.
        """
        a = payloads.GetAttributeListRequestPayload(self.unique_identifier)
        b = payloads.GetAttributeListRequestPayload(self.unique_identifier)

        self.assertFalse(a != b)
        self.assertFalse(b != a)
    def test_equal_on_equal(self):
        """
        Test that the equality operator returns True when comparing two
        GetAttributeList request payloads with the same data.
        """
        a = payloads.GetAttributeListRequestPayload(self.unique_identifier)
        b = payloads.GetAttributeListRequestPayload(self.unique_identifier)

        self.assertTrue(a == b)
        self.assertTrue(b == a)
    def test_not_equal_on_not_equal_unique_identifier(self):
        """
        Test that the inequality operator returns True when comparing two
        GetAttributeList request payloads with different IDs.
        """
        a = payloads.GetAttributeListRequestPayload(self.unique_identifier)
        b = payloads.GetAttributeListRequestPayload('invalid')

        self.assertTrue(a != b)
        self.assertTrue(b != a)
 def test_str_with_no_content(self):
     """
     Test that str can be applied to a GetAttributeList request payload
     with no ID or attribute names.
     """
     payload = payloads.GetAttributeListRequestPayload(None)
     expected = str({'unique_identifier': None})
     observed = str(payload)
     self.assertEqual(expected, observed)
示例#5
0
 def test_unique_identifier_with_invalid_value(self):
     """
     Test that a TypeError is raised when an invalid ID is used to set
     the unique_identifier attribute of a GetAttributeList request payload.
     """
     payload = payloads.GetAttributeListRequestPayload()
     args = (payload, 'unique_identifier', 0)
     self.assertRaisesRegex(TypeError, "unique identifier must be a string",
                            setattr, *args)
 def test_str(self):
     """
     Test that str can be applied to a GetAttributeList request payload.
     """
     payload = payloads.GetAttributeListRequestPayload(
         self.unique_identifier)
     expected = str({'unique_identifier': self.unique_identifier})
     observed = str(payload)
     self.assertEqual(expected, observed)
    def test_not_equal_on_type_mismatch(self):
        """
        Test that the equality operator returns True when comparing a
        GetAttributeList request payload to a non-GetAttributeList request
        payload.
        """
        a = payloads.GetAttributeListRequestPayload(self.unique_identifier)
        b = "invalid"

        self.assertTrue(a != b)
        self.assertTrue(b != a)
    def test_write_with_no_content(self):
        """
        Test that a GetAttributeList request payload with no ID or attribute
        names can be written to a data stream.
        """
        payload = payloads.GetAttributeListRequestPayload()
        stream = utils.BytearrayStream()
        payload.write(stream)

        self.assertEqual(len(self.empty_encoding), len(stream))
        self.assertEqual(str(self.empty_encoding), str(stream))
    def test_write(self):
        """
        Test that a GetAttributeList request payload can be written to a data
        stream.
        """
        payload = payloads.GetAttributeListRequestPayload(
            self.unique_identifier)
        stream = utils.BytearrayStream()
        payload.write(stream)

        self.assertEqual(len(self.full_encoding), len(stream))
        self.assertEqual(str(self.full_encoding), str(stream))
示例#10
0
 def test_repr_with_no_content(self):
     """
     Test that repr can be applied to a GetAttributeList request payload
     with no ID or attribute names.
     """
     payload = payloads.GetAttributeListRequestPayload(None)
     unique_identifier = "unique_identifier={0}".format(
         payload.unique_identifier)
     expected = "GetAttributeListRequestPayload({0})".format(
         unique_identifier)
     observed = repr(payload)
     self.assertEqual(expected, observed)
示例#11
0
 def test_repr(self):
     """
     Test that repr can be applied to a GetAttributeList request payload.
     """
     payload = payloads.GetAttributeListRequestPayload(
         self.unique_identifier)
     unique_identifier = "unique_identifier={0}".format(
         payload.unique_identifier)
     expected = "GetAttributeListRequestPayload({0})".format(
         unique_identifier)
     observed = repr(payload)
     self.assertEqual(expected, observed)
示例#12
0
    def test_read_with_no_content(self):
        """
        Test that a GetAttributeList response payload with no ID or attribute
        names can be read from a data stream.
        """
        payload = payloads.GetAttributeListRequestPayload()

        self.assertEqual(None, payload._unique_identifier)

        payload.read(self.empty_encoding)

        self.assertEqual(None, payload.unique_identifier)
        self.assertEqual(None, payload._unique_identifier)
示例#13
0
    def test_read(self):
        """
        Test that a GetAttributeList request payload can be read from a data
        stream.
        """
        payload = payloads.GetAttributeListRequestPayload()

        self.assertEqual(None, payload._unique_identifier)

        payload.read(self.full_encoding)

        self.assertEqual(self.unique_identifier, payload.unique_identifier)
        self.assertEqual(
            primitives.TextString(value=self.unique_identifier,
                                  tag=enums.Tags.UNIQUE_IDENTIFIER),
            payload._unique_identifier)
示例#14
0
    def test_unique_identifier(self):
        """
        Test that the unique_identifier attribute of a GetAttributeList
        request payload can be properly set and retrieved.
        """
        payload = payloads.GetAttributeListRequestPayload()

        self.assertIsNone(payload.unique_identifier)
        self.assertIsNone(payload._unique_identifier)

        payload.unique_identifier = 'test-unique-identifier'

        self.assertEqual('test-unique-identifier', payload.unique_identifier)
        self.assertEqual(
            primitives.TextString(value='test-unique-identifier',
                                  tag=enums.Tags.UNIQUE_IDENTIFIER),
            payload._unique_identifier)
示例#15
0
 def test_init_with_args(self):
     """
     Test that a GetAttributeList request payload can be constructed with a
     valid value.
     """
     payloads.GetAttributeListRequestPayload('test-unique-identifier', )
示例#16
0
 def test_init(self):
     """
     Test that a GetAttributeList request payload can be constructed with
     no arguments.
     """
     payloads.GetAttributeListRequestPayload()
示例#17
0
 def _create_get_attribute_list_payload(self):
     return payloads.GetAttributeListRequestPayload()