old_contents: # -*- coding: utf-8 -*-
  
  import operator
  
  from midas.compat import imap
  from midas.tests import unittest
  
  class AssociationTreeTests(unittest.TestCase):
  
      def _get_target_cls(self):
          from midas.associate import AssociationTree
          return AssociationTree
  
      def _make_one(self, split_func=lambda s: s.split('.', 1)):
          return self._get_target_cls()(split_func)
  
      def test_single_root(self):
          root = self._make_one()
          self.assertEqual(len(root), 0)
  
      def test_grow_branch(self):
          root = self._make_one()
          root.grow('foo-item', 'foo')
          self.assertEqual(len(root.leafs), 0)
          self.assertEqual(len(root), 1)
          self.assertEqual(root['foo'].leafs, ['foo-item'])
          self.assertEqual(len(root['foo']), 0)
  
      def test_associate(self):
          root = self._make_one()
          root.grow('foo.bar-branch', 'foo.bar')
          root.grow('foo.baz.blup-branch', 'foo.baz.blup')
          self.assertEqual(root.associate('foo'), None)
          self.assertEqual(root.associate('foo.bar'), ['foo.bar-branch'])
          self.assertEqual(root.associate('foo.bar.baz'), ['foo.bar-branch'])
          self.assertEqual(root.associate('foo.baz'), ['foo.baz.blup-branch'])
  
      def test_query(self):
          root = self._make_one()
          root.grow('foo.bar-branch', 'foo.bar')
          result = list(imap(operator.attrgetter('name'), 
                             root.query(lambda n: len(n.leafs) > 0)))
          self.assertEqual(result, ['bar'])
  
  if __name__ == '__main__':  # pragma: no cover
      unittest.main()
  
new_contents: # -*- coding: utf-8 -*-
  
  import operator
  
  from midas.compat import imap
  from midas.tests import unittest
  
  class AssociationTreeTests(unittest.TestCase):
  
      def _get_target_cls(self):
          from midas.associate import AssociationTree
          return AssociationTree
  
      def _make_one(self, split_func=lambda s: s.split('.', 1)):
          return self._get_target_cls()(split_func)
  
      def test_single_root(self):
          root = self._make_one()
          self.assertEqual(len(root), 0)
  
      def test_grow_branch(self):
          root = self._make_one()
          root.grow('foo-item', 'foo')
          self.assertEqual(len(root.leafs), 0)
          self.assertEqual(len(root), 1)
          self.assertEqual(root['foo'].leafs, ['foo-item'])
          self.assertEqual(len(root['foo']), 0)
  
      def test_associate(self):
          root = self._make_one()
          root.grow('foo.bar-branch', 'foo.bar')
          root.grow('foo.baz.blup-branch', 'foo.baz.blup')
          self.assertEqual(root.associate('foo'), None)
          self.assertEqual(root.associate('foo.bar'), ['foo.bar-branch'])
          self.assertEqual(root.associate('foo.bar.baz'), ['foo.bar-branch'])
          self.assertEqual(root.associate('foo.baz'), ['foo.baz.blup-branch'])
  
      def test_query(self):
          root = self._make_one()
          root.grow('foo.bar-branch', 'foo.bar')
          result = list(imap(operator.attrgetter('name'), 
                             root.query(lambda n: len(n.leafs) > 0)))
          self.assertEqual(result, ['bar'])
  
      def test_map(self):
          root = self._make_one()
          root.grow('foo.bar-branch', 'foo.bar')
          root.grow('foo.baz-branch', 'foo.baz')
          result = root.map(['foo', 'foo.bar'])
          self.assertEqual(result, {'foo.bar': ['foo.bar-branch']})
  
  class SplitDomainTests(unittest.TestCase):
  
      pass
  
  if __name__ == '__main__':  # pragma: no cover
      unittest.main()
  
subject: test map method