# Copyright (c) 2020, Jingrow and Contributors
# See license.txt

from __future__ import annotations

import typing

import jingrow
from jingrow.tests.utils import FrappeTestCase

if typing.TYPE_CHECKING:
	from jcloude.jcloude.doctype.app_release.app_release import AppRelease
	from jcloude.jcloude.doctype.app_source.app_source import AppSource


def create_test_app_release(app_source: AppSource, hash: str | None = None) -> "AppRelease":
	"""Create test app release given App source."""
	hash = hash or jingrow.mock("sha1")
	app_release = jingrow.get_pg(
		{
			"doctype": "App Release",
			"app": app_source.app,
			"source": app_source.name,
			"hash": hash,
			"message": "Test Msg",
			"author": "Test Author",
			"deployable": True,
			"status": "Approved",
		}
	).insert(ignore_if_duplicate=True)
	app_release.reload()
	return app_release


class TestAppRelease(FrappeTestCase):
	pass
