Beispiel #1
0
def test_normalize_word(word_original: str, word_expected: str) -> None:
    """Test the _normalize_word with different cases."""

    word_pool = WordPool()
    word_observed = word_pool._normalize_word(word_original)

    assert word_observed == word_expected
Beispiel #2
0
def test_check_accented_characters(word: str, expected: bool) -> None:
    """Test the _check_accented_characters with different cases."""

    word_pool = WordPool()
    obs = word_pool._check_accented_characters(word)

    assert obs == expected
Beispiel #3
0
def test_remove_conjugation_suffix_from_word(word: str, exp: str) -> None:
    """Test the _remove_conjugation_suffix_from_word with different cases."""

    word_pool = WordPool(word)
    obs = word_pool._remove_conjugation_suffix_from_word(word)

    assert obs == exp
Beispiel #4
0
def test_sample_pool_is_reproducible(words: List[str]) -> None:
    """Test that sample_pool is reproducible."""

    word_pool = WordPool(words)
    obs1 = word_pool.sample_pool(n=3)
    obs2 = word_pool.sample_pool(n=3)

    obs1.equals(obs2)
Beispiel #5
0
def test_check_word_length(word: str, min_len: int, max_len: int,
                           exp: bool) -> None:
    """Test the _check_word_length with different cases."""

    word_pool = WordPool()
    obs = word_pool._check_word_length(word, min_len, max_len)

    assert obs == exp
Beispiel #6
0
def test_select_words_of_length_exception() -> None:
    """Test that _select_words_of_length raises exception when appropriate.

    It is appropriate to raise an exception if no min or max length is specified.
    """

    word_pool = WordPool()
    with pytest.raises(ValueError):
        word_pool.select_words_of_length()
Beispiel #7
0
def test_get_default_pool() -> None:
    """Test words._get_default_pool."""

    shape_exp = (55457, )
    word_pool = WordPool()
    word_pool_default = word_pool._get_default_pool()
    shape_obs = word_pool_default.shape

    assert shape_obs == shape_exp
Beispiel #8
0
def test_get_words_meeting_criteria(words: List[str], exp: pd.Series,
                                    how: str) -> None:
    """Test _get_words_meeting_criteria with different cases."""
    word_pool = WordPool(words)
    obs: pd.Series = word_pool._get_words_meeting_criteria(
        func_checks_criteria=lambda x: "yes" == x,
        how=how,
    )

    obs = obs.reset_index(drop=True)
    assert obs.equals(exp)
Beispiel #9
0
def test_clean_conjugation_suffixes(words: List[str],
                                    exp: List[Optional[str]]) -> None:
    """Test the _clean_conjugation_suffixes with different cases."""

    exp: pd.Series = pd.Series(exp, dtype="object")  # type: ignore
    exp = exp.reset_index(drop=True)  # type: ignore
    word_pool = WordPool(words)
    words = pd.Series(words, dtype="object")
    obs = word_pool._clean_conjugation_suffixes(words)
    obs = obs.reset_index(drop=True)

    assert obs.equals(exp)
Beispiel #10
0
def test_select_words_of_length(words: List[str], min_len: Optional[int],
                                max_len: Optional[int],
                                exp: pd.Series) -> None:
    """Test the _select_words_of_length with different cases."""

    word_pool = WordPool(words)
    word_pool.select_words_of_length(min_len, max_len)
    obs: pd.Series = word_pool._pool_cleaned

    obs = obs.reset_index(drop=True)
    exp = exp.reset_index(drop=True)
    obs.equals(exp)