"""
This file demonstrates writing tests using the unittest module. These will pass
when you run "manage.py test".

Replace this with more appropriate tests for your application.
"""

from django.test import TestCase

class SimpleTest(unittest.TestCase):
    def setUp(self):
        '''Every test needs a client.'''
        
        self.client = Client()
    
    def test_details(self):
        ''' Check login page can be open'''
        
        response = self.client.get('/accounts/login/')

        # Check that the response is 200 OK.
        self.assertEqual(response.status_code, 200)
  
    def test_admin_loginin(self):
	''' Check login success. This is the positive case for user story 1.'''
	
        check_login = self.client.login(username='admin', password='admin')
        self.assertEqual(check_login, True)

    def test_login_ip(self):
	''' Check login with correct username and incorrect password.
	This is the negative case for user story 1, login functionality.
	'''
	
        check_login = self.client.login(username='admin', password='affsdf')
        self.assertEqual(check_login, false)

    def test_login_iu(self):
	''' Check login with correct password and incorrect username 
	This is the negative case for user story 1, login functionality.
	'''
	
        check_login = self.client.login(username='sdasdf', password='admin')
        self.assertEqual(check_login, false)
 
    def test_login_cr(self):
	''' Check login to the corresponding page. positive case for user story 1
	'''
	
        check_login = self.client.login(username='admin', password='admin')
        response = self.client.get('/accounts/index/')
        self.assertEqual(response.status_code, 200)
    
    def test_incorrect_login(self):
        '''Check empty login.
        This is the negative case for user story 1, login functionality.
        '''
        
        check_login = self.client.login(username='', password='')
        self.assertEqual(check_login, False)

    def test_admin_loginin(self):
        ''' Check default page can be open'''
        
	response = self.client.get('/accounts/')
        self.assertEqual(response.status_code, 200)    
        
   def test_file_can_be_save(self):
        ''' Positive case: Check the table file is exist 
        This is the test case for user story 2 '''
        
        response = self.client.get('//')
        buttonclick = self.client.button('startSim').click();
	response = self.client.get('/accounts/result.txt')
        self.assertEqual(response.status_code, 200)
        
    
   def test_file_not_exist(self):
        ''' Negative case: Check the table file generated by the simulation is exist.
        This is the test case for user story 2.
        '''
        
        response = self.client.get('//')
        buttonclick = self.client.button('startSim').click();
	response = self.client.get('/accounts/result.txt')
        self.assertEqual(response.status_code, 400)
        
        
   def test_display_img(self):
        ''' Positive Case. Check whether the image can be displayed, if the return code
        is 200, it successs. This is the test case for user story 3, to display the image.
        '''
        
        response = self.client.get('//')
        buttonclick = self.client.button('displayImg').click();
	response = self.client.get('/accounts/result.jpg')
        self.assertEqual(response.status_code, 200)
        
    
   def test_display_img_fail(self):
        ''' Negative case. Check whether the image can be displayed, if it cannot be 
        accessed, it fails. This is the test case for user story 3, to display the image.
        '''
        
        response = self.client.get('//')
        buttonclick = self.client.button('displayImg').click();
	response = self.client.get('/accounts/result.jpg')
        self.assertEqual(response.status_code, 400)
        
        
     def test_mail_to(self):
        ''' Negative case. Check whether the mail to button can link to a new html page.
        This is the test case for user story 4, to display the image.
        '''
        
        response = self.client.get('//')
        buttonclick = self.client.button('mailto').click();
	response = self.client.get('/accounts/mail')
        self.assertEqual(response.status_code, 200)        
        
        
  
   def test_mail_to_fail(self):
        ''' Negative case. Check whether the mail to button can link to a new html page, if it cannot be 
        accessed, it fails. This is the test case for user story 4, to display the image.
        '''
        
        response = self.client.get('//')
        buttonclick = self.client.button('mailto').click();
	response = self.client.get('/accounts/mail')
        self.assertEqual(response.status_code, 400)        
        
        


  
add automation tests