Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
software-dev-7054cem/Test/app_test.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
44 lines (31 sloc)
1.54 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import unittest | |
from app import app | |
class BasicTestsSetup(unittest.TestCase): | |
def setUp(self): | |
app.config['TESTING'] = True | |
app.config['WTF_CSRF_ENABLED'] = False | |
app.config['DEBUG'] = False | |
self.app = app.test_client() | |
self.assertEqual(app.debug, False) | |
# executed after each test | |
def tearDown(self): | |
pass | |
class TestCaseExamples(unittest.TestCase): | |
def test_home_status(self): | |
tester = app.test_client(self) | |
response = tester.get('/', content_type='html/text') | |
self.assertEqual(response.status_code, 200) # (test if the page renders and response is correct ) | |
def test_home_content(self): | |
tester = app.test_client(self) | |
response = tester.get('/', content_type='html/text') | |
self.assertTrue(b'<!DOCTYPE html>\n<html lang="en">\n<head>\n <meta charset="UTF-8">\n <title>Demo</title>\n' in response.data) # passed the test | |
def test_dashboard(self): | |
tester = app.test_client(self) | |
response = tester.get('/dashboard', content_type='html/text') | |
self.assertTrue(b'<!doctype html>\n<html lang="en">\n <head>\n <meta charset="utf-8">\n <meta name="viewport" content="width=device-width, initial-scale=1">\n' in response.data) # passed the test | |
def test_report_id(self): | |
tester = app.test_client(self) | |
response = tester.get('/issue/1', content_type='html/text') | |
self.assertTrue(b'<h2>Issue Details</h2>' in response.data) # passed the test | |
if __name__ == '__main__': | |
unittest.main() |