Ejemplo n.º 1
0
    def test_total_size_validator(self):
        target = ValueTarget(validator=MaxSizeValidator(10))

        self.assertEqual(target.value, b'')

        target.start()

        target.data_received(b'hello')
        target.data_received(b' ')

        self.assertRaises(ValidationError, target.data_received, b'world')
Ejemplo n.º 2
0
    def test_basic(self):
        target = ValueTarget()
        self.assertEqual(target.value, b'')

        target.start()
        self.assertEqual(target.value, b'')

        target.data_received(b'hello')
        target.data_received(b' ')
        target.data_received(b'world')

        self.assertEqual(target.value, b'hello world')
def test_value_target_total_size_validator():
    target = ValueTarget(validator=MaxSizeValidator(10))

    assert target.value == b''

    target.start()

    target.data_received(b'hello')
    target.data_received(b' ')

    with pytest.raises(ValidationError):
        target.data_received(b'world')
Ejemplo n.º 4
0
    def test_basic(self):
        target = ValueTarget()
        self.assertEqual(target.value, b'')

        target.multipart_filename = None

        target.start()
        self.assertTrue(target.multipart_filename is None)
        self.assertEqual(target.value, b'')

        target.data_received(b'hello')
        target.data_received(b' ')
        target.data_received(b'world')

        target.finish()

        self.assertTrue(target.multipart_filename is None)
        self.assertEqual(target.value, b'hello world')
def test_value_target_basic():
    target = ValueTarget()

    assert target.value == b''

    target.multipart_filename = None

    target.start()
    assert target.multipart_filename is None
    assert target.value == b''

    target.data_received(b'hello')
    target.data_received(b' ')
    target.data_received(b'world')

    target.finish()

    assert target.multipart_filename is None
    assert target.value == b'hello world'