Пример #1
0
 def testParseXml(self):
     """
     Makes sure the correct set and list of object dicts is returned given
     the dummy data in bookmarks.xml
     """
     data = open('bookmarks.xml', 'r')
     bookmarks = data.read()
     data.close()
     tags, objs = delicious2fluid.parseXml(bookmarks)
     # There are the expected number of tags
     self.assertEquals(3, len(tags))
     # There are the expected number of objects (one was ignored)
     self.assertEquals(10, len(objs))
     # The objects have the expected keys
     for attribute in ['href', 'hash', 'title', 'tag', 'time',
         'notes', 'meta']:
         self.assertTrue(attribute in objs[0])
     self.assertTrue(isinstance(objs[0]['tag'], list))
Пример #2
0
 def testImportIntoFluidDB(self):
     """
     Ensures that the steps required to import tags and bookmarks into
     FluidDB behave as expected
     """
     unique_ns = str(uuid.uuid4())
     bookmarks = open('bookmarks.xml', 'r')
     tags, objects = delicious2fluid.parseXml(bookmarks.read())
     try:
         delicious2fluid.importIntoFluidDB(tags, objects, USERNAME,
             PASSWORD, 'test/%s' % unique_ns)
         # check there are delicious tags
         header, result = delicious2fluid.call('GET',
             '/namespaces/test/%s/delicious' % unique_ns, returnTags=True)
         for tag in ['hash', 'tag', 'time', 'meta']:
             self.assertTrue(tag in result['tagNames'])
         self.assertEquals(4, len(result['tagNames']))
         # check we have the imported tags along with the title and notes
         # tags
         header, result = delicious2fluid.call('GET',
             '/namespaces/test/%s' % unique_ns, returnTags=True)
         for tag in ['foo', 'bar', 'baz', 'title', 'notes']:
             self.assertTrue(tag in result['tagNames'])
         self.assertEquals(5, len(result['tagNames']))
         # make sure we have the ten expected objects
         for tag in ['foo', 'bar', 'baz', 'title', 'notes']:
             query_tag = 'has test/%s/%s' % (unique_ns, tag)
             headers, result = delicious2fluid.call('GET', '/objects',
                 query=query_tag)
             # there are two objects that are tagged
             self.assertEquals(10, len(result['ids']))
     finally:
         # clean up
         for tag in ['hash', 'tag', 'time', 'meta']:
             delicious2fluid.call('DELETE',
                 '/tags/test/%s/delicious/%s' % (unique_ns, tag))
         for tag in ['foo', 'bar', 'baz', 'title', 'notes']:
             delicious2fluid.call('DELETE',
                 '/tags/test/%s/%s' % (unique_ns, tag))
         delicious2fluid.call('DELETE',
                 '/namespaces/test/%s' % unique_ns)