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)
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)
def test_put(self): unit = Mock() storage = SharedStorage('git', '1234') storage.link = Mock() storage.put(unit) storage.link.assert_called_once_with(unit)