def testWrite(self):
     mc = Session((StorageServiceTest.addr, StorageServiceTest.port), None)
     mc.start()
     service = StorageService(mc)
     service.write(u"{}_A1".format(StorageServiceTest.testSpacePath),
                   b"ABCDE", 10)
     self.assertEqual(
         service.metaData(u"{}_A1".format(
             StorageServiceTest.testSpacePath)), {
                 u"Name": u"_A1",
                 u"Path": u"{}_A1".format(StorageServiceTest.testSpacePath),
                 u"Type": u"Content",
                 u"Size": 36
             })
     self.assertEqual(
         service.readAsString(
             u"{}_A1".format(StorageServiceTest.testSpacePath), 0, 16),
         u"1234567890ABCDEf")
     self.assertEqual(
         service.readAllAsString(u"{}_A1".format(
             StorageServiceTest.testSpacePath)),
         u"1234567890ABCDEfghijklmnopqrstuvwxyz")
     service.write(u"{}_A1".format(StorageServiceTest.testSpacePath),
                   b"defghi", 39)
     self.assertEqual(
         service.metaData(u"{}_A1".format(
             StorageServiceTest.testSpacePath)), {
                 u"Name": u"_A1",
                 u"Path": u"{}_A1".format(StorageServiceTest.testSpacePath),
                 u"Type": u"Content",
                 u"Size": 45
             })
     self.assertEqual(
         service.readAsString(
             u"{}_A1".format(StorageServiceTest.testSpacePath), 35, 10),
         u"z\0\0\0defghi")
     self.assertEqual(
         service.readAsString(
             u"{}_A1".format(StorageServiceTest.testSpacePath), 0, 16),
         u"1234567890ABCDEf")
     mc.stop()
 def testMetaData(self):
     mc = Session((StorageServiceTest.addr, StorageServiceTest.port), None)
     mc.start()
     service = StorageService(mc)
     self.assertEqual(
         service.metaData(u"{}a1".format(StorageServiceTest.testSpacePath)),
         {
             u"Name": u"a1",
             u"Path": u"{}a1".format(StorageServiceTest.testSpacePath),
             u"Type": u"Collection"
         })
     mc.stop()
 def testAppend(self):
     mc = Session((StorageServiceTest.addr, StorageServiceTest.port), None)
     mc.start()
     service = StorageService(mc)
     service.append(u"{}_A1".format(StorageServiceTest.testSpacePath),
                    b"ABCDE")
     self.assertEqual(
         service.metaData(u"{}_A1".format(
             StorageServiceTest.testSpacePath)), {
                 u"Name": u"_A1",
                 u"Path": u"{}_A1".format(StorageServiceTest.testSpacePath),
                 u"Type": u"Content",
                 u"Size": 41
             })
     self.assertEqual(
         service.read(u"{}_A1".format(StorageServiceTest.testSpacePath), 35,
                      6), b"zABCDE")
     mc.stop()