Created
April 25, 2024 17:51
-
-
Save AlvisonHunterArnuero/3f67bb58ca3ac8f3cc6000872ea45cdc to your computer and use it in GitHub Desktop.
Utils file for all of the integration test
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
from typing import List, Any | |
from tabulate import tabulate # type: ignore | |
from datetime import datetime | |
import uuid | |
def is_promo_day(str_date: str, order_promo_day: str) -> bool: | |
""" | |
Check if a given date falls on a promotional day. | |
Args: | |
str_date (str): A date string in the format '%Y-%m-%d %H:%M:%S.%f'. | |
order_promo_day (str): The promotional day string (e.g., 'MON', 'TUE', etc.). | |
Returns: | |
bool: True if the given date falls on the promotional day, False otherwise. | |
""" | |
date_object = datetime.strptime(str_date, "%Y-%m-%d %H:%M:%S.%f") | |
day_of_week = date_object.strftime("%a") | |
return day_of_week.upper() == order_promo_day.upper() | |
def unique_id() -> str: | |
""" | |
Generate a unique identifier (UUIDv4) as a string. | |
Returns: | |
str: A unique identifier string generated using UUIDv4. | |
""" | |
return str(uuid.uuid4()) | |
def print_table(header_title: str, data_src: List[List[Any]], table_header: List[str]) -> None: | |
""" | |
Print a tabulated table with a specified header title and column headers. | |
Args: | |
- header_title (str): The title of the table to be printed. | |
- data_src (List[List[Any]]): A list of lists containing the data to be displayed in the table. | |
- table_header (List[str]): A list of strings representing the column headers of the table. | |
Returns: | |
- None | |
""" | |
print() | |
print(header_title.upper()) | |
print() | |
print(tabulate(data_src, headers=table_header, tablefmt="fancy_grid")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment