Skip to content

Commit

Permalink
Added docstrings to plotting tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Ollie-Gullery committed Apr 12, 2024
1 parent f1ff649 commit 8edb4a2
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/test_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,40 @@

# Check to see if output type is correct given correct inputs
def test_sns_plotting_output_type():
"""_summary_
Ensures that the output of the sns plotting function is a matplotlib figure
"""
result = sns_plotting('scatterplot', data, 'number_of_reviews', 'price', 20, 10)
assert type(result) == matplotlib.figure.Figure, "Test failed: Output type is incorrect."

# Check to see if exception raised for n/a plot type
def test_sns_plotting_plottype_error():
"""_summary_
Ensures that running the sns plotting function with the incorrect inputs leads to an error
"""
with pytest.raises(Exception):
result = sns_plotting('barplot', data, 'number_of_reviews', 'price', 20, 10)

# Check to see if value error raised for x-variable not in data
def test_sns_plotting_x_error():
"""_summary_
Ensures that running the sns plotting function with the incorrect inputs leads to an error
"""
with pytest.raises(ValueError):
sns_plotting('scatterplot', data, 'random_x', 'price', 20, 10)

# Check to see if value error raised for y-variable not in data
def test_sns_plotting_y_error():
"""_summary_
Ensures that running the sns plotting function with the incorrect inputs leads to an error
"""
with pytest.raises(ValueError):
sns_plotting('scatterplot', data, 'number_of_reviews', 'random_y', 20, 10)

# Check to see the figlength and figheight are both <= 25 to avoid being too large
def test_sns_plotting_figsize_check():
"""_summary_
Ensures that the figure size of the sns plot is of a reasonable size (<= 25 inches)
"""
result = sns_plotting('scatterplot', data, 'number_of_reviews', 'price')
assert result.get_size_inches()[0] <= 25 and result.get_size_inches()[1] <= 25, "Test failed: Plot size is too large."

0 comments on commit 8edb4a2

Please # to comment.