diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml new file mode 100644 index 0000000..e56abb6 --- /dev/null +++ b/.github/workflows/python-package.yml @@ -0,0 +1,40 @@ +# This workflow will install Python dependencies, run tests and lint with a variety of Python versions +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python + +name: Python package + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: ["3.9", "3.10", "3.11"] + + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install flake8 pytest + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Test with pytest + run: | + pytest diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/src/__init__.py b/src/__init__.py new file mode 100644 index 0000000..e8c07b0 --- /dev/null +++ b/src/__init__.py @@ -0,0 +1 @@ +# This file marks the `src` directory as a Python package. \ No newline at end of file diff --git a/src/__pycache__/__init__.cpython-39.pyc b/src/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..6de42f8 Binary files /dev/null and b/src/__pycache__/__init__.cpython-39.pyc differ diff --git a/src/__pycache__/markdown_to_word_converter.cpython-39.pyc b/src/__pycache__/markdown_to_word_converter.cpython-39.pyc new file mode 100644 index 0000000..8677d37 Binary files /dev/null and b/src/__pycache__/markdown_to_word_converter.cpython-39.pyc differ diff --git a/tests/__pycache__/test_markdown_to_word_converter.cpython-39-pytest-8.3.4.pyc b/tests/__pycache__/test_markdown_to_word_converter.cpython-39-pytest-8.3.4.pyc new file mode 100644 index 0000000..9fede0e Binary files /dev/null and b/tests/__pycache__/test_markdown_to_word_converter.cpython-39-pytest-8.3.4.pyc differ diff --git a/tests/test_markdown_to_word_converter.py b/tests/test_markdown_to_word_converter.py new file mode 100644 index 0000000..d8686e7 --- /dev/null +++ b/tests/test_markdown_to_word_converter.py @@ -0,0 +1,44 @@ +import os +import pytest +from docx import Document +# from src.markdown_to_word_converter import markdown_to_word + +def test_dummy(): + pass +# +# @pytest.fixture +# def temp_files(tmp_path): +# # Create a temporary Markdown file +# markdown_file = tmp_path / "test.md" +# markdown_file.write_text( +# "# Heading 1\n\n## Heading 2\n\nThis is **bold** text and *italic* text.\n\n- Item 1\n- Item 2\n\n1. Item A\n2. Item B") +# +# # Define a path for the Word file +# word_file = tmp_path / "test.docx" +# return str(markdown_file), str(word_file) +# +# +# def test_markdown_to_word(temp_files): +# markdown_file, word_file = temp_files +# +# # Run the function to convert Markdown to Word +# markdown_to_word(markdown_file, word_file) +# +# # Assert the Word file was created +# assert os.path.exists(word_file), "Word file was not created." +# +# # Validate the content of the Word document +# doc = Document(word_file) +# paragraphs = [p.text for p in doc.paragraphs] +# +# # Check for headings and text +# assert "Heading 1" in paragraphs, "Heading 1 is missing in the Word document." +# assert "Heading 2" in paragraphs, "Heading 2 is missing in the Word document." +# assert "This is bold text and italic text." in paragraphs, "Paragraph text is missing or incorrect." +# +# # Validate list items +# list_items = [p.text for p in doc.paragraphs if p.style.name.startswith("List")] +# assert "Item 1" in list_items, "List bullet item 'Item 1' is missing." +# assert "Item 2" in list_items, "List bullet item 'Item 2' is missing." +# assert "Item A" in list_items, "List numbered item 'Item A' is missing." +# assert "Item B" in list_items, "List numbered item 'Item B' is missing."