def text(self):

        """
        Extract the raw plain text.

        Returns:
            str: The text content.
        """

        ft = self.libmagic_file_type

        # Empty:
        if ft == 'inode/x-empty':
            return None

        # Plaintext:
        elif ft == 'text/plain':
            with open(self.path, 'r') as fh:
                return fh.read()

        # HTML/XML:
        elif ft == 'text/html':
            return utils.html_text(self.path)

        # PDF:
        elif ft == 'application/pdf':
            return utils.pdf_text(self.path)

        # Everything else:
        else:
            return utils.docx_text(self.path)
    def text(self):
        """
        Extract the raw plain text.

        Returns:
            str: The text content.
        """

        ft = self.libmagic_file_type

        # Empty:
        if ft == 'inode/x-empty':
            return None

        # Plaintext:
        elif ft == 'text/plain':
            with open(self.path, 'r') as fh:
                return fh.read()

        # HTML/XML:
        elif ft == 'text/html':
            return utils.html_text(self.path)

        # PDF:
        elif ft == 'application/pdf':
            return utils.pdf_text(self.path)

        # Everything else:
        else:
            return utils.docx_text(self.path)
def test_extract_text(mock_osp):

    """
    Text should be extracted via Tika.
    """

    # Create a .docx.
    path = mock_osp.add_file(content='text', ftype='docx')

    # Should extract the text.
    text = docx_text(path).strip()
    assert text == 'text'