# from django.urls import resolve
from selenium import webdriver

from django.test import TestCase

# from django.template.loader import render_to_string

# from .views import go_to_home_page

# Create your tests here.

class HomePageTest(TestCase):

	def test_home_page_returns_correct_html(self):
		response = self.client.get('/')

		# html = response.content.decode('utf8')

		# expected_html = render_to_string('home_page.html')

		# self.assertTrue(html.startswith('<html>'))
		# self.assertIn('<title>The Good Place</title>',html)
		# self.assertTrue(html.endswith('</html>'))
		# self.assertEqual(html, expected_html)

		self.assertTemplateUsed(response, 'home_page.html')



class IngredientsListTest(TestCase):

	def test_ingredients_list_page_returns_correct_html(self):
		response = self.client.get('/ingredients/list')
		self.assertTemplateUsed(response, 'ingredients_list.html')

class IngredientsDetailTest(TestCase):

	def test_ingredients_detail_page_returns_correct_html(self):
		response = self.client.get('/ingredients/detail')
		self.assertTemplateUsed(response, 'ingredients_detail.html')

class IngredientsUpdateTest(TestCase):

	def test_ingredients_update_page_returns_correct_html(self):
		response = self.client.get('/ingredients/update')
		self.assertTemplateUsed(response, 'ingredients_update_form.html')

class IngredientsCreateTest(TestCase):

	def test_ingredients_create_page_returns_correct_html(self):
		response = self.client.get('/ingredients/create')
		self.assertTemplateUsed(response, 'ingredients_create_form.html')




class RecipesListTest(TestCase):

	def test_recipes_list_page_returns_correct_html(self):
		response = self.client.get('/recipes/list')
		self.assertTemplateUsed(response, 'recipes_list.html')

class RecipesDetailTest(TestCase):

	def test_recipes_detail_page_returns_correct_html(self):
		response = self.client.get('/recipes/detail')
		self.assertTemplateUsed(response, 'recipes_detail.html')

class RecipesUpdateTest(TestCase):

	def test_recipes_update_page_returns_correct_html(self):
		response = self.client.get('/recipes/update')
		self.assertTemplateUsed(response, 'recipes_update_form.html')

class RecipesCreateTest(TestCase):

	def test_recipes_create_page_returns_correct_html(self):
		response = self.client.get('/recipes/create')
		self.assertTemplateUsed(response, 'recipes_create_form.html')




class OrdersListTest(TestCase):

	def test_orders_list_page_returns_correct_html(self):
		response = self.client.get('/orders/list')
		self.assertTemplateUsed(response, 'orders_list.html')

class OrdersDetailTest(TestCase):

	def test_orders_detail_page_returns_correct_html(self):
		response = self.client.get('/orders/detail')
		self.assertTemplateUsed(response, 'orders_detail.html')

class OrdersUpdateTest(TestCase):

	def test_orders_update_page_returns_correct_html(self):
		response = self.client.get('/orders/update')
		self.assertTemplateUsed(response, 'orders_update_form.html')

class OrdersCreateTest(TestCase):

	def test_orders_create_page_returns_correct_html(self):
		response = self.client.get('/orders/create')
		self.assertTemplateUsed(response, 'orders_create_form.html')

# class IngredientsListButtonTest(TestCase):

# 	def setUp(self):
# 		self.browser = webdriver.Firefox()

# 	def tearDown(self):
# 		self.browser.quit()

# 	def test_ingredients_list_button_click_redirects_to_correct_html(self):
		
# 		self.browser.get('http://localhost:8000/')
# 		response = self.client.get('/')

# 		# self.assertTrue(self.browser.find_element_by_id("ingredients_list"))
# 		# elem = self.browser.find_element_by_id("ingredients_list")

# 		self.assertTrue(self.browser.find_element_by_id("ingredients_list"))
# 		elem = self.browser.find_element_by_id("ingredients_list")

# 		elem.click()

		