Skip to content

Commit

Permalink
Merge pull request #128 from toonarmycaptain/development
Browse files Browse the repository at this point in the history
Development - UI tests, bump for release 0.3.0-alpha
  • Loading branch information
toonarmycaptain authored Jan 23, 2019
2 parents f2e5997 + 21cf5ea commit 2916abf
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 10 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [0.3.0-alpha] - 2019-01-23
### Added
- Improved test coverage.
- Add Contact note, saythanks.io badge to README.
- Add currently unimplemented select_student/take_student_selection functions mirroring similar class selection functionality.
- Select class/student dialogues will now take exact name of class/student (as well as integer).
- Select class/student dialogues will now take exact name of class/student (as well as integer per user direction), note this is to be considered an implementation detail, since a class with an integer name will only be selectable by entering that name if the integer is not displayed/larger that the number of options.
### Changed
- Bugfixes
- Fix path for default_avatar.
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from setuptools import setup, find_packages

setup(name='dionysus_app',
version='0.2.0-alpha',
version='0.3.0-alpha',
description='Avatar chart generator',
author='David Antonini',
author_email='toonarmycaptain@hotmail.com',
Expand Down
78 changes: 71 additions & 7 deletions test_suite/UI_menus_tests/test_class_functions_UI.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
take_student_name_input,
blank_class_dialogue,
class_data_feedback,
take_class_selection,
)
from test_suite.testing_class_data import (testing_registry_data_set as test_registry_data_set,
test_display_class_selection_menu_output,
Expand Down Expand Up @@ -192,22 +193,21 @@ def setUp(self):
self.blank_input = '_'
self.junk_input_knights = 'the knights who say ni'
self.junk_input_questions = ('First you must answer three questions: \n'
'What is your name?\n'
'What is your quest?\n'
'What is your favourite colour?')
'What is your name?\n'
'What is your quest?\n'
'What is your favourite colour?')
# Valid inputs:
# 'No' inputs:
# 'No' inputs:
self.n_input = 'n', False
self.N_input = 'N', False
# 'Yes' inputs:
# 'Yes' inputs:
self.y_input = 'y', True
self.Y_input = 'Y', True


self.blank_junk_inputs = [self.no_input, self.space_input, self.junk_input_knights, self.junk_input_questions]
self.valid_inputs = [self.n_input, self.N_input, self.y_input, self.Y_input]


# Create test sequences:
self.input_sets = []
for valid_input in self.valid_inputs:
test_case = [self.blank_junk_inputs + [valid_input[0]], valid_input[1]]
Expand Down Expand Up @@ -274,6 +274,70 @@ def test_display_class_selection_menu(self):
assert mocked_print.call_args_list == print_calls


class TestTakeClassSelection(TestCase):
def setUp(self):
self.test_class_options = test_registry_data_set['enumerated_dict']
self.invalid_input_response = "Invalid input.\nPlease enter the integer beside the name of the desired class."

# Blank or junk inputs:
self.no_input = ''
self.space_input = ' '
self.blank_input = '_'
self.junk_input_knights = 'the knights who say ni'
self.junk_input_questions = ('First you must answer three questions: \n'
'What is your name?\n'
'What is your quest?\n'
'What is your favourite colour?')
self.negative_input = '-7'
self.zero_0_input = '0'
self.reasonable_float = '2.0'
self.weird_float = '3.14159'
self.positive_out_of_range_input = '17'
# Valid inputs: (valid_input, return_value)
# Numerical
self.valid_numerical_inputs = [(str(key), self.test_class_options[key]) for key in self.test_class_options.keys()]
# Exact class name
self.valid_string_inputs = [(class_name, class_name) for class_name in self.test_class_options.values()]

self.blank_junk_inputs = [self.no_input,
self.space_input,
self.junk_input_knights,
self.junk_input_questions,
self.negative_input,
self.zero_0_input,
self.reasonable_float,
self.weird_float,
self.positive_out_of_range_input,
]

self.valid_inputs = self.valid_numerical_inputs + self.valid_string_inputs

self.input_sets = []
for valid_input in self.valid_inputs:
test_case = [self.blank_junk_inputs + [valid_input[0]], valid_input[1]]
self.input_sets.append(test_case)

@patch('dionysus_app.UI_menus.class_functions_UI.print')
def test_take_class_selection(self, mock_print):
with patch('dionysus_app.UI_menus.class_functions_UI.input') as mock_input:
for test_case in self.input_sets:
with self.subTest(i=test_case):
input_strings = test_case[0]
expected_return = test_case[1]

mock_input.side_effect = input_strings

assert take_class_selection(self.test_class_options) == expected_return

# Check print calls:
assert mock_print.call_args_list == [mock.call(self.invalid_input_response)
for input_string in input_strings[0:-1]]

# Reset the mock function after each test sequence:
mock_input.reset_mock(return_value=True, side_effect=True)
mock_print.reset_mock(return_value=True, side_effect=True)


class TestDisplayStudentSelectionMenu(TestCase):
def setUp(self):
self.enumerated_classlist = test_class_data_set['enumerated_dict']
Expand Down

0 comments on commit 2916abf

Please sign in to comment.