def check_letter_after_word_horizontal_test(): function = check_variant.check_variant_after_letter_horizontal orientation = "h" test_cases_equality = [] # Check letter after incorrect word = "dfb" coordinates = (0, 1) rectangular_array = [ ["_", "_", "a", "_"], ["_", "_", "b", "X"], ["_", "_", "c", "_"], ] answer = False canvas = create_canvas(rectangular_array) variant = create_variant(coordinates, word, orientation) test_cases_equality.append( Assertions.TestCase(params=(variant, canvas), correct=answer)) # Check letter after correct word = "dfb" coordinates = (0, 1) rectangular_array = [ ["_", "_", "a", "_"], ["_", "_", "b", "_"], ["_", "_", "c", "_"], ] answer = True canvas = create_canvas(rectangular_array) variant = create_variant(coordinates, word, orientation) test_cases_equality.append( Assertions.TestCase(params=(variant, canvas), correct=answer)) return Assertions.assert_equal(function, test_cases_equality)
def text_to_words_test(): function = text_words_ops.text_to_words test_cases_equality = [ Assertions.TestCase(params='abc der jkl', correct=['abc', 'der', 'jkl']), Assertions.TestCase(params='abc', correct=['abc']), Assertions.TestCase(params='', correct=[]), ] return Assertions.assert_equal(function, test_cases_equality)
def partially_shuffle_words_test(): function = text_words_ops.partially_shuffle_words # if coefficient is equal to or bigger than length of words they won't be shuffled test_cases_equality = [ Assertions.TestCase(params=(['abc', 'def', 'qwer', 'rtefvff'], 4), correct=['abc', 'def', 'qwer', 'rtefvff']), Assertions.TestCase(params=(['abc', 'def', 'qwer', 'rtefvff'], 6), correct=['abc', 'def', 'qwer', 'rtefvff']) ] # seamless coefficient 0 throws ValueError test_cases_assertion = [ Assertions.TestCase(params=(['abc', 'def'], 0), correct=ValueError) ] return Assertions.assert_raises( function, test_cases_assertion) and Assertions.assert_equal( function, test_cases_equality)
def check_hovering_horizontal_test(): function = check_variant.check_variant_horizontal orientation = "h" test_cases_equality = [] # Check hovering word = "qabq" coordinates = (0, 1) rectangular_array = [ ["_", "_", "_"], ["_", "a", "b"], ["_", "_", "_"], ] answer = False canvas = create_canvas(rectangular_array) variant = create_variant(coordinates, word, orientation) test_cases_equality.append( Assertions.TestCase(params=(variant, canvas), correct=answer)) return Assertions.assert_equal(function, test_cases_equality)
def check_cell_taken_vertical_test(): function = check_variant.check_variant_vertical orientation = "v" test_cases_equality = [] # Check letter taken incorrect word = "abcd" coordinates = (1, 0) rectangular_array = [ ["_", "_", "_"], ["a", "b", "c"], ["_", "X", "_"], ["_", "_", "_"], ] answer = False canvas = create_canvas(rectangular_array) variant = create_variant(coordinates, word, orientation) test_cases_equality.append( Assertions.TestCase(params=(variant, canvas), correct=answer)) return Assertions.assert_equal(function, test_cases_equality)
def remove_redundant_symbols_test(): function = text_words_ops.remove_redundant_symbols test_cases_equality = [ Assertions.TestCase(params='qwert', correct='qwert'), Assertions.TestCase(params='qw!@#$ert', correct='qwert'), Assertions.TestCase(params='', correct=''), Assertions.TestCase(params='q wer\nty abc', correct='q wer\nty abc'), Assertions.TestCase(params='0a1b2c3d4e5f6', correct='abcdef'), Assertions.TestCase(params='abcабв', correct='abcабв'), ] return Assertions.assert_equal(function, test_cases_equality)
def check_words_amount_test(): function = words_check.check_words_amount test_cases_equality = [Assertions.TestCase(params=(['abc', 'de'], 2), correct=True), Assertions.TestCase(params=(['abc', 'de'], 1), correct=False), Assertions.TestCase(params=(['abc', 'de'], 3), correct=True), Assertions.TestCase(params=([], 2), correct=True)] test_cases_raising = [Assertions.TestCase(params=(['abc'], 0), correct=ValueError)] return Assertions.assert_equal(function, test_cases_equality, first_element=True) and Assertions.assert_raises( function, test_cases_raising)
def check_text_symbol_occurrences_test(): function = text_check.check_text_symbol_occurrences test_cases_equality = [ Assertions.TestCase(params=('abc', 2), correct=True), Assertions.TestCase(params=('abbc', 1), correct=False), Assertions.TestCase(params=('abccc', 3), correct=True), Assertions.TestCase(params=('', 2), correct=True) ] test_cases_raising = [ Assertions.TestCase(params=('abc', 0), correct=ValueError) ] return Assertions.assert_equal( function, test_cases_equality, first_element=True) and Assertions.assert_raises( function, test_cases_raising)
def check_text_total_length_test(): function = text_check.check_text_total_length test_cases_equality = [ Assertions.TestCase(params=('ab', 5), correct=True), Assertions.TestCase(params=('abbc', 2), correct=False), Assertions.TestCase(params=('abc', 3), correct=True), Assertions.TestCase(params=('', 2), correct=True) ] test_cases_raising = [ Assertions.TestCase(params=('abc', 0), correct=ValueError) ] return Assertions.assert_equal( function, test_cases_equality, first_element=True) and Assertions.assert_raises( function, test_cases_raising)
def check_letter_left_right_word_vertical_test(): function = check_variant.check_variant_vertical orientation = "v" test_cases_equality = [] # Check letter left incorrect word = "abcb" coordinates = (2, 0) rectangular_array = [ ["_", "_", "_"], ["_", "X", "_"], ["_", "_", "_"], ["c", "a", "b"], ] answer = False canvas = create_canvas(rectangular_array) variant = create_variant(coordinates, word, orientation) test_cases_equality.append( Assertions.TestCase(params=(variant, canvas), correct=answer)) # Check letter left correct word = "abcb" coordinates = (2, 0) rectangular_array = [ ["_", "_", "_"], ["_", "_", "_"], ["_", "_", "_"], ["c", "a", "b"], ] answer = True canvas = create_canvas(rectangular_array) variant = create_variant(coordinates, word, orientation) test_cases_equality.append( Assertions.TestCase(params=(variant, canvas), correct=answer)) # Check letter right incorrect word = "abcb" coordinates = (2, 0) rectangular_array = [ ["_", "_", "_", "_"], ["_", "_", "_", "X"], ["_", "_", "_", "_"], ["c", "a", "b", "_"], ] answer = False canvas = create_canvas(rectangular_array) variant = create_variant(coordinates, word, orientation) test_cases_equality.append( Assertions.TestCase(params=(variant, canvas), correct=answer)) # Check letter right correct word = "abcb" coordinates = (2, 0) rectangular_array = [ ["_", "_", "_", "_"], ["_", "_", "_", "_"], ["_", "_", "_", "_"], ["c", "a", "b", "_"], ] answer = True canvas = create_canvas(rectangular_array) variant = create_variant(coordinates, word, orientation) test_cases_equality.append( Assertions.TestCase(params=(variant, canvas), correct=answer)) return Assertions.assert_equal(function, test_cases_equality)