Exemplo n.º 1
0
    def test_link(self, symlink):
        unit = Mock(id='0123456789')
        storage = SharedStorage('git', '1234')

        # test
        storage.link(unit)

        # validation
        expected_path = os.path.join(storage.links_dir, unit.id)
        symlink.assert_called_once_with(storage.content_dir, expected_path)
        self.assertEqual(unit.storage_path, expected_path)
Exemplo n.º 2
0
    def test_duplicate_link(self, islink, readlink, symlink):
        unit = Mock(id='0123456789')
        storage = SharedStorage('git', '1234')

        islink.return_value = True
        symlink.side_effect = OSError()
        symlink.side_effect.errno = EEXIST
        readlink.return_value = storage.content_dir

        # test
        storage.link(unit)
        # note: not exception raised

        # validation
        expected_path = os.path.join(storage.links_dir, unit.id)
        symlink.assert_called_once_with(storage.content_dir, expected_path)
        self.assertEqual(unit.storage_path, expected_path)
Exemplo n.º 3
0
 def test_put(self):
     unit = Mock()
     storage = SharedStorage('git', '1234')
     storage.link = Mock()
     storage.put(unit)
     storage.link.assert_called_once_with(unit)