# -*- coding: utf-8 -*-
# Copyright (c) 2020, JINGROW
# See license.txt

import typing
import unittest

import jingrow

from jcloud.jcloud.pagetype.app_source.app_source import AppSource

if typing.TYPE_CHECKING:
	from jcloud.jcloud.pagetype.app_release.app_release import AppRelease


def create_test_app_release(app_source: AppSource, hash: str = None) -> "AppRelease":
	"""Create test app release given App source."""
	hash = hash or jingrow.mock("sha1")
	app_release = jingrow.get_pg(
		{
			"pagetype": "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(unittest.TestCase):
	pass
