# Copyright (c) 2015, InfluxFramework LLC
# License: MIT. See LICENSE

import influxframework
from influxframework.tests.utils import InfluxFrameworkTestCase

test_records = influxframework.get_test_records("Custom Field")


class TestCustomField(InfluxFrameworkTestCase):
	def test_create_custom_fields(self):
		from .custom_field import create_custom_fields

		create_custom_fields(
			{
				"Address": [
					{
						"fieldname": "_test_custom_field_1",
						"label": "_Test Custom Field 1",
						"fieldtype": "Data",
						"insert_after": "phone",
					},
				],
				("Address", "Contact"): [
					{
						"fieldname": "_test_custom_field_2",
						"label": "_Test Custom Field 2",
						"fieldtype": "Data",
						"insert_after": "phone",
					},
				],
			}
		)

		influxframework.db.commit()

		self.assertTrue(influxframework.db.exists("Custom Field", "Address-_test_custom_field_1"))
		self.assertTrue(influxframework.db.exists("Custom Field", "Address-_test_custom_field_2"))
		self.assertTrue(influxframework.db.exists("Custom Field", "Contact-_test_custom_field_2"))
