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


import jingrow
from jingrow.tests.utils import FrappeTestCase

from jcloude.jcloude.pagetype.cluster.test_cluster import create_test_cluster


def create_test_jcloude_settings():
	"""Create test jcloude settings pg"""
	create_test_cluster()
	if not jingrow.db.exists("TLS Certificate", "*.fc.dev"):
		jingrow.get_pg(
			{
				"pagetype": "TLS Certificate",
				"name": "*.fc.dev",
				"domain": "fc.dev",
				"wildcard": True,
				"status": "Active",
				"rsa_key_size": 2048,
			}
		).db_insert()

	jingrow.get_pg(
		{
			"pagetype": "Root Domain",
			"name": "fc.dev",
			"dns_provider": "AWS Route 53",
			"default_cluster": "Default",
			"aws_access_key_id": jingrow.mock("password"),
			"aws_secret_access_key": jingrow.mock("password"),
		}
	).insert(ignore_if_duplicate=True)

	settings = jingrow.get_single("Jcloude Settings")
	settings.domain = "fc.dev"
	settings.bench_configuration = "{}"
	settings.rsa_key_size = 2048
	settings.certbot_directory = ".certbot"
	settings.eff_registration_email = jingrow.mock("email")
	settings.max_concurrent_physical_restorations = 2
	settings.minimum_rebuild_memory = 2
	settings.save()
	return settings


class TestPressSettings(FrappeTestCase):
	pass
