Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions tests/test_plot_data.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from pathlib import Path

import pandas as pd
import pytest

Expand All @@ -8,28 +7,28 @@

@pytest.fixture
def sample_csv(tmp_path: Path) -> Path:
"""Create a sample CSV file for testing."""
df = pd.DataFrame({"x": [1.0, 2.0, 3.0, 4.0, 5.0], "y": [2.0, 4.0, 6.0, 8.0, 10.0]})
"""Creates and returns a sample CSV file for testing."""
file_path = tmp_path / "test.csv"
df = pd.DataFrame({"x": range(1, 6), "y": [2 * i for i in range(1, 6)]})
df.to_csv(file_path, index=False)
return file_path


def test_read_csv_data(sample_csv: Path) -> None:
"""Test reading data from CSV file."""
"""Tests reading data from a CSV file."""
x_data, y_data = read_csv_data(sample_csv, "x", "y")
assert x_data == [1.0, 2.0, 3.0, 4.0, 5.0]
assert y_data == [2.0, 4.0, 6.0, 8.0, 10.0]
assert x_data == [1, 2, 3, 4, 5]
assert y_data == [2, 4, 6, 8, 10]


def test_create_plot() -> None:
"""Test plot creation."""
x_data = [1.0, 2.0, 3.0]
y_data = [2.0, 4.0, 6.0]
"""Tests plot creation and verifies labels and title."""
x_data, y_data = [1, 2, 3], [2, 4, 6]
fig = create_plot(x_data, y_data, "X", "Y", "Test Plot")

assert fig is not None
# Basic check that the figure contains the expected elements
ax = fig.axes[0]

assert ax.get_xlabel() == "X"
assert ax.get_ylabel() == "Y"
assert ax.get_title() == "Test Plot"