Files
MyManagingTools/tests/conftest.py

67 lines
1.4 KiB
Python

from io import BytesIO
import pandas as pd
import pytest
from components.datagrid.DataGrid import reset_instances
USER_EMAIL = "test@mail.com"
USER_ID = "test_user"
@pytest.fixture
def excel_file_content():
# Create a simple Excel file in memory
df = pd.DataFrame({
'Column 1': ['Aba', 'Johan', 'Kodjo'],
'Column 2': ['Female', 'Male', 'Male']
})
excel_io = BytesIO()
df.to_excel(excel_io, index=False)
excel_io.seek(0)
return excel_io.read()
@pytest.fixture
def excel_file_content_2():
# Create a simple Excel file in memory
df = pd.DataFrame({
'Column 1': ['C', 'A', 'B'],
'Column 2': [1, 2, 3]
})
excel_io = BytesIO()
df.to_excel(excel_io, index=False)
excel_io.seek(0)
return excel_io.read()
@pytest.fixture
def excel_file_content_with_sheet_name():
# Create a DataFrame
df = pd.DataFrame({
'Column 1 ': ['Aba', 'Johan', 'Kodjo'],
'Column 2': [False, True, True],
'Column 3 ': [10, 20, 30],
})
# Create an in-memory bytes buffer
excel_io = BytesIO()
# Write the dataframe to the buffer with a custom sheet name
df.to_excel(excel_io, index=False, sheet_name="sheet_name")
# Move the pointer to the start of the stream
excel_io.seek(0)
return excel_io.read() # Return the binary data
@pytest.fixture(autouse=True)
def reset_datagrid_instances():
reset_instances()
@pytest.fixture
def session():
return {"user_id": USER_ID, "user_email": USER_EMAIL}