21 lines
621 B
Python
21 lines
621 B
Python
import csv
|
|
|
|
from src.generate_data import generate_data
|
|
|
|
|
|
def test_record_count_and_header(tmp_path):
|
|
path = tmp_path / "orders.csv"
|
|
generate_data(path)
|
|
with path.open(encoding="utf-8", newline="") as source:
|
|
records = csv.reader(source)
|
|
assert next(records) == ["order_id", "order_date", "category", "quantity", "unit_price"]
|
|
assert sum(1 for _ in records) == 1500
|
|
|
|
|
|
def test_repeated_generation_is_byte_identical(tmp_path):
|
|
path = tmp_path / "orders.csv"
|
|
generate_data(path)
|
|
first_run = path.read_bytes()
|
|
generate_data(path)
|
|
assert path.read_bytes() == first_run
|