Notes![what is notes.io? What is notes.io?](/theme/images/whatisnotesio.png)
![]() ![]() Notes - notes.io |
import unittest
from app import app
import logging
import os
import openpyxl
from openpyxl import Workbook
from datetime import datetime
# Global variables for Excel file and sheet name
EXCEL_FILE = 'test_results.xlsx'
SHEET_NAME = 'Test Results'
class FlaskTestCase(unittest.TestCase):
def setUp(self):
self.tester = app.test_client(self)
app.config['TESTING'] = True
def test_check_column_names(self):
response = self.tester.get("/columnnames")
result = response.get_json()
# print("this is result",result['session_id'])
try:
self.assertEqual(response.status_code, 200)
result_msg = "pass"
except AssertionError:
result_msg = "fail"
# Log test result to Excel report
log_to_excel(EXCEL_FILE, SHEET_NAME, "test_check_column_names", "check_column_names", result_msg)
def test_export_column_names(self):
response = self.tester.get("/exportcolumnnames")
try:
self.assertEqual(response.status_code, 200)
result_msg = "pass"
except AssertionError:
result_msg = "fail"
log_to_excel(EXCEL_FILE, SHEET_NAME, "test_export_column_names", "export_column_names", result_msg)
def test_revert_record_history(self):
params_dict = {"revert_timestamp":["2024-06-26 14:14:59.920000"],"sourceFileUniqueId":["dd57ec80d781851862dc5fd4f8e3b481b521bb8aa52c913990a95906"]}
expected_output = {"modified_count": 0}
response = self.tester.post('/revert_record_history', json=params_dict)
result = response.get_json()
# self.assertEqual(result, expected_output, "revert_record_history: fail")
# print("revert_record_history: pass")
# if result == expected_output:
# result_msg = "pass"
# else:
# result_msg = "fail"
try:
self.assertEqual(result, expected_output)
result_msg = "pass"
except AssertionError:
result_msg = "fail"
log_to_excel(EXCEL_FILE, SHEET_NAME, "test_revert_record_history", "revert_record_history", result_msg)
log_to_excel(EXCEL_FILE, SHEET_NAME, "test_revert_record_history","revert_record_history", result_msg)
def log_to_excel(filename, sheet_name, test_name, api_name,result):
if os.path.exists(filename):
workbook = openpyxl.load_workbook(filename)
else:
workbook = Workbook()
if sheet_name in workbook.sheetnames:
sheet = workbook[sheet_name]
else:
sheet = workbook.create_sheet(sheet_name)
sheet.append(["Timestamp", "Test Name", "API NAME","Result"])
sheet.append([datetime.now().strftime("%Y-%m-%d %H:%M:%S"), test_name,api_name, result])
workbook.save(filename)
if __name__ == "__main__":
CONFIG_FILE_PATH = os.path.dirname(__file__)
def process_cfg_file():
configuration = Configuration()
configuration.configRead(os.path.join(CONFIG_FILE_PATH, "app.cfg"))
process_cfg_file()
FORMAT = "[%(asctime)s %(filename)s->%(funcName)s():%(lineno)s]%(levelname)s: %(message)s"
logging.basicConfig(format=FORMAT)
unittest.main()
![]() |
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team