Ejemplo n.º 1
0
 def test_file_node_repr(self):
     """Test Rest conversion of a file node."""
     f1 = MockNode()
     info = self.mapper.node_repr(f1)
     self.assertEqual(info['key'], f1.nodekey)
     self.assertEqual(info['kind'], f1.kind.lower())
     self.assertEqual(info['path'], f1.full_path)
     self.assertEqual(info['hash'], f1.content_hash)
     self.assertEqual(
         info['when_created'], date_formatter(f1.when_created))
     self.assertEqual(
         info['when_changed'], date_formatter(f1.when_last_modified))
     self.assertEqual(info['generation'], f1.generation)
     self.assertEqual(info['generation_created'], f1.generation_created)
     self.assertEqual(info['public_url'], f1.public_url)
     self.assertEqual(info['is_public'], f1.is_public)
     self.assertEqual(
         info['parent_path'], "/~/Ubuntu One/a/b/c/d")
     self.assertEqual(
         info['volume_path'], "/volumes/~/Ubuntu One")
     self.assertEqual(
         info['content_path'], '/content/~/Ubuntu One/a/b/c/d/file.txt')
     # make sure file specific rules apply
     self.assertTrue('has_children' not in info)
     self.assertEqual(info['is_live'], True)
Ejemplo n.º 2
0
 def test_root_dir_node_repr(self):
     """Utility method to test Rest conversion of a root directory node."""
     f1 = MockNode()
     f1.kind = StorageObject.DIRECTORY
     f1.name = ""
     f1.path = '/'
     f1.full_path = "/"
     info = self.mapper.node_repr(f1)
     self.assertEqual(info['key'], f1.nodekey)
     self.assertEqual(info['kind'], f1.kind.lower())
     self.assertEqual(info['path'], f1.full_path)
     self.assertEqual(info['when_created'], date_formatter(f1.when_created))
     self.assertEqual(
         info['when_changed'], date_formatter(f1.when_last_modified))
     self.assertEqual(info['generation'], f1.generation)
     self.assertEqual(info['generation_created'], f1.generation_created)
     self.assertEqual(info['parent_path'], None)
     self.assertEqual(info['volume_path'], "/volumes/~/Ubuntu One")
     self.assertEqual(info['content_path'], '/content/~/Ubuntu One')
     # make sure directory specific rules apply
     self.assertTrue('hash' not in info)
     self.assertTrue('is_public' not in info)
     self.assertTrue('public_url' not in info)
     self.assertTrue('has_children' in info)
     self.assertEqual(info['is_live'], True)
Ejemplo n.º 3
0
 def test_dir_node_repr(self):
     """Utility method to test Rest conversion of a directory node."""
     f1 = MockNode()
     f1.kind = 'Directory'
     info = self.mapper.node_repr(f1)
     self.assertEquals(info['key'], f1.nodekey)
     self.assertEquals(info['kind'], f1.kind.lower())
     self.assertEquals(info['path'], f1.full_path)
     self.assertEquals(info['when_created'],
                       date_formatter(f1.when_created))
     self.assertEquals(info['when_changed'],
                       date_formatter(f1.when_last_modified))
     self.assertEquals(info['generation'], f1.generation)
     self.assertEquals(info['generation_created'], f1.generation_created)
     self.assertEquals(info['parent_path'],
                       "/~/Ubuntu One/a/b/c/d")
     self.assertEquals(info['volume_path'],
                       "/volumes/~/Ubuntu One")
     self.assertEquals(info['content_path'],
                       u'/content/~/Ubuntu One/a/b/c/d/file.txt')
     # make sure directory specific rules apply
     self.assertTrue('hash' not in info)
     self.assertTrue('is_public' not in info)
     self.assertTrue('public_url' not in info)
     self.assertTrue('has_children' in info)
     self.assertEquals(info['is_live'], True)
Ejemplo n.º 4
0
 def test_root_dir_node_repr(self):
     """Utility method to test Rest conversion of a root directory node."""
     f1 = MockNode()
     f1.kind = 'Directory'
     f1.name = ""
     f1.path = '/'
     f1.full_path = "/"
     info = self.mapper.node_repr(f1)
     self.assertEquals(info['key'], f1.nodekey)
     self.assertEquals(info['kind'], f1.kind.lower())
     self.assertEquals(info['path'], f1.full_path)
     self.assertEquals(info['when_created'],
                       date_formatter(f1.when_created))
     self.assertEquals(info['when_changed'],
                       date_formatter(f1.when_last_modified))
     self.assertEquals(info['generation'], f1.generation)
     self.assertEquals(info['generation_created'], f1.generation_created)
     self.assertEquals(info['parent_path'], None)
     self.assertEquals(info['volume_path'], "/volumes/~/Ubuntu One")
     self.assertEquals(info['content_path'], u'/content/~/Ubuntu One')
     # make sure directory specific rules apply
     self.assertTrue('hash' not in info)
     self.assertTrue('is_public' not in info)
     self.assertTrue('public_url' not in info)
     self.assertTrue('has_children' in info)
     self.assertEquals(info['is_live'], True)
Ejemplo n.º 5
0
 def test_volume_repr(self):
     """Test Rest conversion of a volume."""
     udf = MockVolume()
     info = self.mapper.volume_repr(udf)
     self.assertEqual(info['resource_path'], '/volumes/~/Documents')
     self.assertEqual(info['type'], 'root' if udf.is_root else 'udf')
     self.assertEqual(info['path'], udf.path)
     self.assertEqual(info['generation'], udf.generation)
     self.assertEqual(info['node_path'], self.mapper.node(udf.path))
     self.assertEqual(
         info['when_created'], date_formatter(udf.when_created))
Ejemplo n.º 6
0
 def test_volume_repr(self):
     """Test Rest conversion of a volume."""
     udf = MockVolume()
     info = self.mapper.volume_repr(udf)
     self.assertEquals(info['resource_path'], u'/volumes/~/Documents')
     self.assertEquals(info['type'], u'root' if udf.is_root else u'udf')
     self.assertEquals(info['path'], udf.path)
     self.assertEquals(info['generation'], udf.generation)
     self.assertEquals(info['node_path'], self.mapper.node(udf.path))
     self.assertEquals(info['when_created'],
                       date_formatter(udf.when_created))
Ejemplo n.º 7
0
 def test_file_node_repr(self):
     """Test Rest conversion of a file node."""
     f1 = MockNode()
     info = self.mapper.node_repr(f1)
     self.assertEquals(info['key'], f1.nodekey)
     self.assertEquals(info['kind'], f1.kind.lower())
     self.assertEquals(info['path'], f1.full_path)
     self.assertEquals(info['hash'], f1.content_hash)
     self.assertEquals(info['when_created'],
                       date_formatter(f1.when_created))
     self.assertEquals(info['when_changed'],
                       date_formatter(f1.when_last_modified))
     self.assertEquals(info['generation'], f1.generation)
     self.assertEquals(info['generation_created'], f1.generation_created)
     self.assertEquals(info['public_url'], f1.public_url)
     self.assertEquals(info['is_public'], f1.is_public)
     self.assertEquals(info['parent_path'], "/~/Ubuntu One/a/b/c/d")
     self.assertEquals(info['volume_path'], "/volumes/~/Ubuntu One")
     self.assertEquals(info['content_path'],
                       u'/content/~/Ubuntu One/a/b/c/d/file.txt')
     # make sure file specific rules apply
     self.assertTrue('has_children' not in info)
     self.assertEquals(info['is_live'], True)
Ejemplo n.º 8
0
 def test_volume_with_delta_repr0(self):
     """Test Rest conversion of a vol with delta information, no nodes."""
     udf = MockVolume()
     nodes = []
     info = self.mapper.volume_repr(
         volume=udf, from_generation=0, nodes=nodes)
     self.assertEqual(info['resource_path'], '/volumes/~/Documents')
     self.assertEqual(info['type'], 'root' if udf.is_root else 'udf')
     self.assertEqual(info['path'], udf.path)
     self.assertEqual(info['generation'], udf.generation)
     self.assertEqual(info['node_path'], self.mapper.node(udf.path))
     self.assertEqual(
         info['when_created'], date_formatter(udf.when_created))
     self.assertEqual(info['delta']['from_generation'], 0)
     self.assertEqual(info['delta']['nodes'], nodes)
Ejemplo n.º 9
0
 def test_volume_with_delta_repr0(self):
     """Test Rest conversion of a vol with delta information, no nodes."""
     udf = MockVolume()
     nodes = []
     info = self.mapper.volume_repr(volume=udf,
                                    from_generation=0,
                                    nodes=nodes)
     self.assertEquals(info['resource_path'], u'/volumes/~/Documents')
     self.assertEquals(info['type'], u'root' if udf.is_root else u'udf')
     self.assertEquals(info['path'], udf.path)
     self.assertEquals(info['generation'], udf.generation)
     self.assertEquals(info['node_path'], self.mapper.node(udf.path))
     self.assertEquals(info['when_created'],
                       date_formatter(udf.when_created))
     self.assertEquals(info['delta']['from_generation'], 0)
     self.assertEquals(info['delta']['nodes'], nodes)