This repository has been archived on 2022-07-15. You can view files and clone it, but cannot push or open issues or pull requests.
mmp-osp1/test/unit/test_dataset.py
Oscar Pocock 523f518aa8
Some checks failed
ci/woodpecker/push/lint Pipeline failed
ci/woodpecker/push/test Pipeline failed
Final submission commit
A few changes:
- Added report
- Added mid project demo content
- Added README.txt
- Added Experiments
- Added ratings.txt file
- Added unit tests
- Simplified the prediction code
- Added single prediction
2022-05-14 17:44:05 +01:00

35 lines
No EOL
1.2 KiB
Python

from autophotographer.cnn import dataset
from unittest import mock
import pytest
import pandas as pd
@mock.patch("pandas.read_csv")
def test_calculate_image_rating_with_no_ratings(mock_read_csv):
testEntry = "1 1 0 0 0 0 0 0 0 0 0 0 -1 -1 -1"
testEntry = testEntry.split()
testEntry = list(map(int, testEntry))
df = pd.DataFrame([testEntry])
mock_read_csv.return_value = df
index = 1
assert dataset.calculate_image_rating(index) == 0
@mock.patch("pandas.read_csv")
def test_calculate_image_rating_multiple_ratings(mock_read_csv):
testEntry = "1 1 1 2 3 4 5 6 7 8 9 10 -1 -1 -1"
testEntry = testEntry.split()
testEntry = list(map(int, testEntry))
df = pd.DataFrame([testEntry])
mock_read_csv.return_value = df
index = 1
assert dataset.calculate_image_rating(index) == 7
@mock.patch("pandas.read_csv")
def test_calculate_image_rating_incorrect_number_of_columns(mock_read_csv):
with pytest.raises(ValueError):
testEntry = "1 1 1 2 3 4 5 6 7 8 9 10 -1 -1 -1 9 9 9"
testEntry = testEntry.split()
testEntry = list(map(int, testEntry))
df = pd.DataFrame([testEntry])
mock_read_csv.return_value = df
index = 1
assert dataset.calculate_image_rating(index)