Beispiel #1
0
    def test__valid_separator_valid(self):
        """Test ``_valid_separator`` for a valid separator.

        If the separator and data are valid, result is ``True``.

        Input:
        - Table data (pandas.DataFrame)
        Output:
        - True (bool).
        """
        # Setup
        columns = ['b', 'c']
        instance = UniqueCombinations(columns=columns)
        instance._separator = '#'

        # Run
        table_data = pd.DataFrame({
            'a': ['a', 'b', 'c'],
            'b': ['d', 'e', 'f'],
            'c': ['g', 'h', 'i']
        })
        is_valid = instance._valid_separator(table_data)

        # Assert
        assert is_valid
Beispiel #2
0
    def test__valid_separator_non_valid_separator_contained(self):
        """Test ``_valid_separator`` passing a column that contains the separator.

        If any of the columns contains the separator string, result is ``False``.

        Input:
        - Table data (pandas.DataFrame) with a column that contains the separator string ('#')
        Output:
        - False (bool).
        """
        # Setup
        columns = ['b', 'c']
        instance = UniqueCombinations(columns=columns)
        instance._separator = '#'

        # Run
        table_data = pd.DataFrame({
            'a': ['a', 'b', 'c'],
            'b': ['d', '#', 'f'],
            'c': ['g', 'h', 'i']
        })
        is_valid = instance._valid_separator(table_data)

        # Assert
        assert not is_valid
Beispiel #3
0
    def test__valid_separator_non_valid_name_joined_exists(self):
        """Test ``_valid_separator`` passing a column whose name is obtained after joining
        the column names using the separator.

        If the column name obtained after joining the column names using the separator
        already exists, result is ``False``.

        Input:
        - Table data (pandas.DataFrame) with a column name that will be obtained by joining
        the column names and the separator.
        Output:
        - False (bool).
        """
        # Setup
        columns = ['b', 'c']
        instance = UniqueCombinations(columns=columns)
        instance._separator = '#'

        # Run
        table_data = pd.DataFrame({
            'b#c': ['a', 'b', 'c'],
            'b': ['d', 'e', 'f'],
            'c': ['g', 'h', 'i']
        })
        is_valid = instance._valid_separator(table_data)

        # Assert
        assert not is_valid