def test_already_created(self, lib): path = '/tmp/path-1' _lib = Mock() lib.return_value = _lib # test repo = Repository(path) repo.impl = Mock() repo.create() # validation self.assertFalse(_lib.OSTree.Repo.new.called)
def test_create(self, lib): fp = Mock() path = '/tmp/path-1' lib_repo = Mock() _lib = Mock() _lib.GLib.GError = GError _lib.Gio.File.new_for_path.return_value = fp _lib.OSTree.Repo.new.return_value = lib_repo lib.return_value = _lib # test repo = Repository(path) repo.create() # validation lib.assert_called_with() _lib.Gio.File.new_for_path.assert_called_once_with(path) _lib.OSTree.Repo.new.assert_called_once_with(fp) lib_repo.create.assert_called_once_with(_lib.OSTree.RepoMode.ARCHIVE_Z2, None)
def test_open(self, lib): fp = Mock() path = '/tmp/path-1' lib_repo = Mock() _lib = Mock() _lib.Gio.File.new_for_path.return_value = fp _lib.OSTree.Repo.new.return_value = lib_repo lib.return_value = _lib # test repo = Repository(path) repo.create() # validation lib.assert_called_with() _lib.Gio.File.new_for_path.assert_called_once_with(path) _lib.OSTree.Repo.new.assert_called_once_with(fp) lib_repo.open.assert_called_once_with(None) self.assertFalse(lib_repo.create.called)