from django.test import LiveServerTestCase, TestCase
from selenium import webdriver
import doctest
import pug.nlp.util
import pug.nlp.djdb

class HomeTest(LiveServerTestCase):

    def setUp(self):
        self.browser = webdriver.Firefox()
        self.browser.implicitly_wait(1)

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

    def test_home_page(self):
        # Angeline opens her web browser, and goes to the home (root url) page
        self.browser.get(self.live_server_url + '/')

        # She sees the word start somewhere
        body = self.browser.find_element_by_tag_name('body')
        self.assertTrue(bool(body.text))


class AdminTest(LiveServerTestCase):
    pass
    # def setUp(self):
    #     self.browser = webdriver.Firefox()
    #     self.browser.implicitly_wait(1)

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

    # def test_admin_interface_login_page(self):
    #     # Angeline opens her web browser, and goes to the admin page
    #     self.browser.get(self.live_server_url + '/admin')

    #     # She sees the phrase 'Django administration' somewhere in the body
    #     body = self.browser.find_element_by_tag_name('body')
    #     self.assertIn('Django administration', body.text)



class DocTest(TestCase):

    def test_util(self, module=pug.nlp.util):
        failure_count, test_count = doctest.testmod(module, raise_on_error=False, verbose=True)
        msg = "Ran {0} tests in {3} and {1} passed ({2} failed)".format(test_count, test_count-failure_count, failure_count, module.__file__)
        print msg
        if failure_count:
            self.fail(msg)

    def test_djdb(self, module=pug.nlp.djdb):
        failure_count, test_count = doctest.testmod(module, raise_on_error=False, verbose=True)
        msg = "Ran {0} tests in {3} and {1} passed ({2} failed)".format(test_count, test_count-failure_count, failure_count, module.__file__)
        print msg
        if failure_count:
            self.fail(msg)
@@ -1238,16 +1238,18 @@
 ext)%0A%0A%0A%0A
+# 
 class Do
@@ -1258,32 +1258,34 @@
 est(TestCase):%0A%0A
+# 
     def test_uti
@@ -1314,16 +1314,18 @@
 .util):%0A
+# 
         
@@ -1408,32 +1408,33 @@
 rbose=True)%0A
+#
         
 msg = %22Ran %7B
@@ -1413,32 +1413,33 @@
 =True)%0A#        
+ 
 msg = %22Ran %7B0%7D t
@@ -1548,32 +1548,34 @@
 odule.__file__)%0A
+# 
         print ms
@@ -1568,32 +1568,34 @@
       print msg%0A
+# 
         if failu
@@ -1596,32 +1596,33 @@
  failure_count:%0A
+#
             self
@@ -1609,32 +1609,33 @@
 t:%0A#            
+ 
 self.fail(msg)%0A%0A
@@ -1634,16 +1634,18 @@
 l(msg)%0A%0A
+# 
     def 
@@ -1682,16 +1682,18 @@
 .djdb):%0A
+# 
         
@@ -1780,16 +1780,18 @@
 e=True)%0A
+# 
         
@@ -1924,16 +1924,18 @@
 file__)%0A
+# 
         
@@ -1944,16 +1944,18 @@
 int msg%0A
+# 
         
@@ -1972,16 +1972,18 @@
 _count:%0A
+# 
         

comment out tests of djdb and util