
# # # from selenium import webdriver
# # # import time
# # # browser = webdriver.Chrome('/Users/parvathi/Downloads/chromedriver')

# # # browser.get('http://127.0.0.1:5000/home')
# # # time.sleep(2)
# # # browser.find_element_by_name("username").send_keys('parvathi11')
# # # browser.find_element_by_name("password").send_keys('std101')
# # # browser.find_element_by_name("choice").send_keys('student')
# # # x='//*[@id="LOGIN"]'
# # # ele1=browser.find_element_by_xpath(x)
# # # ele1.click()
# # # time.sleep(2)


# # # browser.get('http://127.0.0.1:5000/home')
# # # time.sleep(2)
# # # browser.find_element_by_name("username").send_keys('deepakm11')
# # # browser.find_element_by_name("password").send_keys('fac101')
# # # browser.find_element_by_name("choice").send_keys('faculty')
# # # x='//*[@id="LOGIN"]'
# # # ele1=browser.find_element_by_xpath(x)
# # # ele1.click()

# # # from selenium import webdriver
# # # import time
# # # browser = webdriver.Chrome('/Users/parvathi/Downloads/chromedriver')

# # # browser.get('http://127.0.0.1:5000/home')
# # # time.sleep(2)
# # # browser.find_element_by_name("username").send_keys('parvathi11')
# # # browser.find_element_by_name("password").send_keys('std101')
# # # browser.find_element_by_name("choice").send_keys('student')
# # # x='//*[@id="LOGIN"]'
# # # ele1=browser.find_element_by_xpath(x)
# # # ele1.click()
# # # time.sleep(2)

# # # browser.get('http://127.0.0.1:5000/home')
# # # time.sleep(2)
# # # browser.find_element_by_name("username").send_keys('deepakm11')
# # # browser.find_element_by_name("password").send_keys('fac101')
# # # browser.find_element_by_name("choice").send_keys('faculty')
# # # x='//*[@id="LOGIN"]'
# # # ele1=browser.find_element_by_xpath(x)
# # # ele1.click()
# # # time.sleep(2)

# # # browser.get('http://127.0.0.1:5000/dashboard')
# # # time.sleep(2)
# # # browser.get('http://127.0.0.1:5000/issues-view-faculty')
# # # ele1=browser.find_element_by_xpath(x)
# # # ele1.click()
# # # time.sleep(2)

# # # browser.get('http://127.0.0.1:5000/dashboard')
# # # time.sleep(2)
# # # browser.get('http://127.0.0.1:5000/od-applications')
# # # ele1=browser.find_element_by_xpath(x)
# # # ele1.click()
# # # time.sleep(2)

# # # from selenium import webdriver
# # # import time
# # # browser = webdriver.Chrome('/Users/parvathi/Downloads/chromedriver')

# # # browser.get('http://127.0.0.1:5000/home')
# # # time.sleep(2)
# # # browser.find_element_by_name("username").send_keys('parvathi11')
# # # browser.find_element_by_name("password").send_keys('std101')
# # # browser.find_element_by_name("choice").send_keys('student')
# # # x='//*[@id="LOGIN"]'
# # # ele1=browser.find_element_by_xpath(x)
# # # ele1.click()
# # # time.sleep(2)

# # # browser.get('http://127.0.0.1:5000/home')
# # # time.sleep(2)
# # # browser.find_element_by_name("username").send_keys('deepakm11')
# # # browser.find_element_by_name("password").send_keys('fac101')
# # # browser.find_element_by_name("choice").send_keys('faculty')
# # # x='//*[@id="LOGIN"]'
# # # ele1=browser.find_element_by_xpath(x)
# # # ele1.click()
# # # time.sleep(2)

# # # browser.get('http://127.0.0.1:5000/dashboard')
# # # time.sleep(2)
# # # browser.get('http://127.0.0.1:5000/issues-view-faculty')
# # # time.sleep(2)

# # # browser.get('http://127.0.0.1:5000/dashboard')
# # # time.sleep(2)
# # # browser.get('http://127.0.0.1:5000/course_list_for_faculty')

# # # time.sleep(2)

# # # browser.get('http://127.0.0.1:5000/dashboard')
# # # time.sleep(2)
# # # browser.get('http://127.0.0.1:5000/od-update-date-and-hour')

# # # time.sleep(2)

# # # browser.get('http://127.0.0.1:5000/dashboard')
# # # time.sleep(2)
# # # browser.get('http://127.0.0.1:5000/change-attendance-status-date-hour-course-form')

# # # time.sleep(2)

# # from selenium import webdriver
# # import time
# # browser = webdriver.Chrome('/Users/parvathi/Downloads/chromedriver')

# # browser.get('http://127.0.0.1:5000/home')
# # time.sleep(2)
# # browser.find_element_by_name("username").send_keys('parvathi11')
# # browser.find_element_by_name("password").send_keys('std101')
# # browser.find_element_by_name("choice").send_keys('student')
# # x='//*[@id="LOGIN"]'
# # ele1=browser.find_element_by_xpath(x)
# # ele1.click()
# # time.sleep(2)
# # browser.get('http://127.0.0.1:5000/raise-issue-form')
# # browser.find_element_by_name("date").send_keys('02/03/2020')
# # browser.find_element_by_name("time").send_keys('2')
# # browser.find_element_by_name("fid").send_keys('fac101')
# # browser.find_element_by_name("cid").send_keys('cse125')
# # browser.find_element_by_name("remark").send_keys('I was on OD')
# # x='//*[@id="myDiv"]/form/input[6]'
# # ele1=browser.find_element_by_xpath(x)
# # ele1.click()
# # time.sleep(2)
# # browser.get('http://127.0.0.1:5000/attendance-report-form')
# # browser.find_element_by_name("course").send_keys('cse123')
# # x='/html/body/form/input[2]'
# # ele1=browser.find_element_by_xpath(x)
# # ele1.click()
# # time.sleep(2)
# # browser.get('http://127.0.0.1:5000/view-issues-students')
# # time.sleep(2)


# # browser.get('http://127.0.0.1:5000/home')
# # time.sleep(2)
# # browser.find_element_by_name("username").send_keys('deepakm11')
# # browser.find_element_by_name("password").send_keys('fac101')
# # browser.find_element_by_name("choice").send_keys('faculty')
# # x='//*[@id="LOGIN"]'
# # ele1=browser.find_element_by_xpath(x)
# # ele1.click()
# # time.sleep(2)



# # browser.get('http://127.0.0.1:5000/dashboard')
# # time.sleep(2)
# # browser.get('http://127.0.0.1:5000/issues-view-faculty')
# # time.sleep(2)

# # browser.get('http://127.0.0.1:5000/dashboard')
# # time.sleep(2)
# # browser.get('http://127.0.0.1:5000/course_list_for_faculty')

# # time.sleep(2)

# # browser.get('http://127.0.0.1:5000/dashboard')
# # time.sleep(2)
# # browser.get('http://127.0.0.1:5000/od-update-date-and-hour')
# # time.sleep(2)

# # browser.get('http://127.0.0.1:5000/dashboard')
# # time.sleep(2)
# # browser.get('http://127.0.0.1:5000/change-attendance-status-date-hour-course-form')
# # browser.get('http://127.0.0.1:5000/home')



# # time.sleep(2)
# import unittest

# class TestStringMethods(unittest.TestCase):

#     def test_upper(self):
#         self.assertEqual('foo'.upper(), 'FOO')

#     def test_isupper(self):
#         self.assertTrue('FOO'.isupper())
#         self.assertFalse('Foo'.isupper())

#     def test_split(self):
#         s = 'hello world'
#         self.assertEqual(s.split(), ['hello', 'world'])
#         # check that s.split fails when the separator is not a string
#         with self.assertRaises(TypeError):
#             s.split(2)

# if __name__ == '__main__':
#     unittest.main()

import unittest
import pymysql
import pymysql.cursors
class TestStringMethods(unittest.TestCase):

    def test_student_login(self):
        con = pymysql.connect(host='localhost', user='dev', password='Parvathi', db='swdb')
        cur = con.cursor()
        faculty_id = "fac103"
        cur.execute('select * from faculty_login where faculty_id=%s', faculty_id)
        rows = cur.fetchall()
        for row in rows:
            self.assertEqual(row[0], 'fac103')


    def test_faculty_login(self):
        con = pymysql.connect(host='localhost', user='dev', password='Parvathi', db='swdb')
        cur = con.cursor()
        student_id = "std102"
        cur.execute('select * from student_login where student_id=%s', student_id)
        rows = cur.fetchall()
        for row in rows:
            self.assertEqual(row[0], 'std102')


    def test_course(self):
        con = pymysql.connect(host='localhost', user='dev', password='Parvathi', db='swdb')
        cur = con.cursor()
        course_id = "std102"
        cur.execute('SELECT * FROM course_details where course_id=%s', course_id)
        rows = cur.fetchall()
        for row in rows:
            self.assertEqual(row[0] , 'C Programming')


    def test_facultyid(self):
        con = pymysql.connect(host='localhost', user='dev', password='Parvathi', db='swdb')
        cur = con.cursor()
        faculty_id = "cse123"
        cur.execute('SELECT * FROM faculty where faculty_id=%s', faculty_id)
        rows = cur.fetchall()
        for row in rows:
            self.assertEqual(row[1], 'Deepak')


    def test_faculty_notification(self):
        con = pymysql.connect(host='localhost', user='dev', password='Parvathi', db='swdb')
        cur = con.cursor()
        faculty_id = "fac101"
        fac_notif_id="1"
        cur.execute('SELECT * FROM faculty_notification where faculty_id=%s and fac_notif_id=%s', (faculty_id,fac_notif_id))
        rows = cur.fetchall()
        for row in rows:
            self.assertEqual(row[2], 'ISSUE RAISED BY X STUDENT')



    def test_faculty_course_handling(self):
        con = pymysql.connect(host='localhost', user='dev', password='Parvathi', db='swdb')
        cur = con.cursor()
        faculty_id = "fac102"
        cur.execute('SELECT * FROM faculty_to_course where faculty_id=%s', faculty_id)
        rows = cur.fetchall()
        for row in rows:
            self.assertEqual(row[2], 'cse124')


    def test_student_advisor(self):
        con = pymysql.connect(host='localhost', user='dev', password='Parvathi', db='swdb')
        cur = con.cursor()
        student_id = "cse234"
        cur.execute('SELECT * FROM student where student_id=%s', student_id)
        rows = cur.fetchall()
        for row in rows:
            self.assertEqual(row[3], 'cse121')

    def test_student_course(self):
        con = pymysql.connect(host='localhost', user='dev', password='Parvathi', db='swdb')
        cur = con.cursor()
        student_id = "std101"
        course_id = "cse124"
        cur.execute('SELECT * FROM student_to_course where student_id=%s and course_id=%s', (student_id,course_id))
        rows = cur.fetchall()

        for row in rows:
            print(row[2])
            # self.assertEqual(row[2], 'fac102')




if __name__ == '__main__':
    unittest.main()
