from __future__ import absolute_import
import unittest

from afpproxy import afp, afpcommands, dsi, proxy


class AFPNameTests(unittest.TestCase):
    def test_api(self):
        afpcommands.take_name
        afpcommands.AFPName
        obj = afpcommands.AFPName()
        self.assertTrue(callable(obj))

    def test_short_name(self):
        name, data = afpcommands.take_name('\x01\x08example')
        self.assertEqual(name, 'example')
        self.assertEqual(len(data), 0)

    def test_long_name(self):
        name, data = afpcommands.take_name('\x02\x08example')
        self.assertEqual(name, 'example')
        self.assertEqual(len(data), 0)

    def test_utf8_name(self):
        name, data = afpcommands.take_name('\x03\x00\x00\x01\x00\x00\x07example')
        self.assertEqual(name, 'example')
        self.assertEqual(len(data), 0)


if __name__ == "__main__":
    unittest.main()
