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


import unittest
from typing import Optional
from unittest.mock import patch

import jingrow

from jcloud.jcloud.pagetype.account_request.account_request import AccountRequest


def create_test_account_request(
	subdomain: str,
	email: str = None,
	jerp: bool = True,
	creation=None,
	saas: bool = False,
	saas_app: Optional[str] = None,
):
	creation = creation or jingrow.utils.now_datetime()
	email = email or jingrow.mock("email")
	with patch.object(AccountRequest, "send_verification_email"):
		account_request = jingrow.get_pg(
			{
				"pagetype": "Account Request",
				"subdomain": subdomain,
				"email": email,
				"jerp": jerp,
				"saas": saas,
				"saas_app": saas_app,
				"otp": "",
			}
		).insert(ignore_if_duplicate=True)
		account_request.db_set("creation", creation)
		account_request.reload()
		return account_request


class TestAccountRequest(unittest.TestCase):
	pass
