Skip to content
Snippets Groups Projects
Commit 78020d43 authored by Sukanya K's avatar Sukanya K
Browse files

added unit testcase removed not needed files

parent 7a0c3b17
No related branches found
No related tags found
No related merge requests found
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# Virtual environment
venv/
.env/
# Distribution / packaging
.Python
dist/
build/
*.egg-info/
*.egg/
# Logs and databases
*.log
db.sqlite3
db.sqlite
# Testing
.coverage
.tox/
nosetests.xml
pytest_cache/
# Jupyter Notebook
.ipynb_checkpoints
# IDE configurations
.vscode/
.idea/
# Cache files
*.cache
*.pyc
# Environment variables
.envrc
.env
*.secret
# Local settings
settings_local.py
# Docker
.dockerignore
# Miscellaneous
*.bak
Thumbs.db
.DS_Store
# ReadWriteExcel
## Getting started
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
## Add your files
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
```
cd existing_repo
git remote add origin https://gitlab.niveussolutions.com/sukanya.k/ReadWriteExcel.git
git branch -M master
git push -uf origin master
```
## Integrate with your tools
- [ ] [Set up project integrations](https://gitlab.niveussolutions.com/sukanya.k/ReadWriteExcel/-/settings/integrations)
## Collaborate with your team
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
- [ ] [Set auto-merge](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
## Test and Deploy
Use the built-in continuous integration in GitLab.
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/)
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
***
# Editing this README
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template.
## Suggestions for a good README
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
## Name
Choose a self-explaining name for your project.
## Description
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
## Badges
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
## Visuals
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
## Installation
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
## Usage
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
## Support
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
## Roadmap
If you have ideas for releases in the future, it is a good idea to list them in the README.
## Contributing
State if you are open to contributions and what your requirements are for accepting them.
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
## Authors and acknowledgment
Show your appreciation to those who have contributed to the project.
## License
For open source projects, say how it is licensed.
## Project status
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
File deleted
File deleted
File deleted
File deleted
<?xml version="1.0" ?>
<coverage version="7.7.1" timestamp="1742813846643" lines-valid="207" lines-covered="156" line-rate="0.7536" branches-covered="0" branches-valid="0" branch-rate="0" complexity="0">
<coverage version="7.7.1" timestamp="1742968491065" lines-valid="235" lines-covered="218" line-rate="0.9277" branches-covered="0" branches-valid="0" branch-rate="0" complexity="0">
<!-- Generated by coverage.py: https://coverage.readthedocs.io/en/7.7.1 -->
<!-- Based on https://raw.githubusercontent.com/cobertura/web/master/htdocs/xml/coverage-04.dtd -->
<sources>
<source>/home/user/Documents/Hindu/ReadtowriteExcel</source>
</sources>
<packages>
<package name="." line-rate="0.1639" branch-rate="0" complexity="0">
<package name="." line-rate="0.7377" branch-rate="0" complexity="0">
<classes>
<class name="__init__.py" filename="__init__.py" complexity="0" line-rate="1" branch-rate="0">
<methods/>
......@@ -37,60 +37,60 @@
<line number="7" hits="0"/>
</lines>
</class>
<class name="process_data.py" filename="process_data.py" complexity="0" line-rate="0" branch-rate="0">
<class name="process_data.py" filename="process_data.py" complexity="0" line-rate="0.7609" branch-rate="0">
<methods/>
<lines>
<line number="3" hits="0"/>
<line number="4" hits="0"/>
<line number="5" hits="0"/>
<line number="6" hits="0"/>
<line number="7" hits="0"/>
<line number="11" hits="0"/>
<line number="13" hits="0"/>
<line number="14" hits="0"/>
<line number="17" hits="0"/>
<line number="24" hits="0"/>
<line number="25" hits="0"/>
<line number="27" hits="0"/>
<line number="28" hits="0"/>
<line number="3" hits="1"/>
<line number="4" hits="1"/>
<line number="5" hits="1"/>
<line number="6" hits="1"/>
<line number="7" hits="1"/>
<line number="11" hits="1"/>
<line number="13" hits="1"/>
<line number="14" hits="1"/>
<line number="17" hits="1"/>
<line number="24" hits="1"/>
<line number="25" hits="1"/>
<line number="27" hits="1"/>
<line number="28" hits="1"/>
<line number="29" hits="0"/>
<line number="30" hits="0"/>
<line number="33" hits="0"/>
<line number="36" hits="0"/>
<line number="33" hits="1"/>
<line number="36" hits="1"/>
<line number="37" hits="0"/>
<line number="38" hits="0"/>
<line number="40" hits="0"/>
<line number="43" hits="0"/>
<line number="45" hits="0"/>
<line number="46" hits="0"/>
<line number="48" hits="0"/>
<line number="49" hits="0"/>
<line number="50" hits="0"/>
<line number="53" hits="0"/>
<line number="54" hits="0"/>
<line number="55" hits="0"/>
<line number="56" hits="0"/>
<line number="40" hits="1"/>
<line number="43" hits="1"/>
<line number="45" hits="1"/>
<line number="46" hits="1"/>
<line number="48" hits="1"/>
<line number="49" hits="1"/>
<line number="50" hits="1"/>
<line number="53" hits="1"/>
<line number="54" hits="1"/>
<line number="55" hits="1"/>
<line number="56" hits="1"/>
<line number="57" hits="0"/>
<line number="59" hits="0"/>
<line number="60" hits="0"/>
<line number="61" hits="0"/>
<line number="59" hits="1"/>
<line number="60" hits="1"/>
<line number="61" hits="1"/>
<line number="64" hits="0"/>
<line number="65" hits="0"/>
<line number="67" hits="0"/>
<line number="67" hits="1"/>
<line number="68" hits="0"/>
<line number="70" hits="0"/>
<line number="71" hits="0"/>
<line number="72" hits="0"/>
<line number="74" hits="0"/>
<line number="77" hits="0"/>
<line number="83" hits="0"/>
<line number="86" hits="0"/>
<line number="87" hits="0"/>
<line number="74" hits="1"/>
<line number="77" hits="1"/>
<line number="83" hits="1"/>
<line number="86" hits="1"/>
<line number="87" hits="1"/>
</lines>
</class>
</classes>
</package>
<package name="tests" line-rate="1" branch-rate="0" complexity="0">
<package name="tests" line-rate="0.9927" branch-rate="0" complexity="0">
<classes>
<class name="__init__.py" filename="tests/__init__.py" complexity="0" line-rate="1" branch-rate="0">
<methods/>
......@@ -193,6 +193,39 @@
<line number="53" hits="1"/>
</lines>
</class>
<class name="test_process_data.py" filename="tests/test_process_data.py" complexity="0" line-rate="0.9643" branch-rate="0">
<methods/>
<lines>
<line number="1" hits="1"/>
<line number="2" hits="1"/>
<line number="3" hits="1"/>
<line number="4" hits="1"/>
<line number="6" hits="1"/>
<line number="7" hits="1"/>
<line number="8" hits="1"/>
<line number="9" hits="1"/>
<line number="10" hits="1"/>
<line number="11" hits="1"/>
<line number="12" hits="1"/>
<line number="14" hits="1"/>
<line number="17" hits="1"/>
<line number="18" hits="1"/>
<line number="19" hits="1"/>
<line number="23" hits="1"/>
<line number="24" hits="1"/>
<line number="27" hits="1"/>
<line number="28" hits="1"/>
<line number="29" hits="1"/>
<line number="30" hits="1"/>
<line number="33" hits="1"/>
<line number="36" hits="1"/>
<line number="39" hits="1"/>
<line number="42" hits="1"/>
<line number="43" hits="1"/>
<line number="45" hits="1"/>
<line number="46" hits="0"/>
</lines>
</class>
<class name="test_unpack_data.py" filename="tests/test_unpack_data.py" complexity="0" line-rate="1" branch-rate="0">
<methods/>
<lines>
......
No preview for this file type
File deleted
import pytest
import openpyxl
from utils.excel_operations import load_excel, save_excel, create_output_workbook
import os
@pytest.fixture
def sample_workbook(tmp_path):
"""Create a sample workbook for testing."""
file_path = tmp_path / "test.xlsx"
workbook = openpyxl.Workbook()
sheet = workbook.active
sheet.append(["Name", "Age", "City"])
sheet.append(["John Doe", 30, "New York"])
workbook.save(file_path)
return file_path
def test_load_excel(sample_workbook):
"""Test loading an existing Excel file."""
workbook = load_excel(sample_workbook)
sheet = workbook.active
assert sheet.cell(row=1, column=1).value == "Name"
assert sheet.cell(row=2, column=1).value == "John Doe"
def test_save_excel(tmp_path):
"""Test saving an Excel file."""
workbook = openpyxl.Workbook()
sheet = workbook.active
sheet.append(["Product", "Price"])
sheet.append(["Laptop", 1200])
file_path = tmp_path / "output.xlsx"
save_excel(workbook, file_path)
# Verify the file is created and data is saved correctly
loaded_workbook = openpyxl.load_workbook(file_path)
loaded_sheet = loaded_workbook.active
assert loaded_sheet.cell(row=1, column=1).value == "Product"
assert loaded_sheet.cell(row=2, column=2).value == 1200
def test_create_output_workbook():
"""Test creating a new workbook with headers."""
headers = ["ID", "Name", "Department"]
workbook = create_output_workbook(headers)
sheet = workbook.active
assert sheet.cell(row=1, column=1).value == "ID"
assert sheet.cell(row=1, column=3).value == "Department"
import unittest
from unittest.mock import patch, MagicMock
from process_data import process_rows
from config import OUTPUT_HEADERS # Import the actual OUTPUT_HEADERS
class TestProcessRows(unittest.TestCase):
@patch("process_data.load_excel") # Mock Excel loading
@patch("process_data.create_output_workbook") # Mock output workbook creation
@patch("process_data.save_excel") # Mock Excel saving
@patch("process_data.send_api_request") # Mock API request
@patch("process_data.unpack_input_data") # Mock unpacking input data
def test_process_rows(self, mock_unpack, mock_api_request, mock_save_excel, mock_create_output, mock_load_excel):
# Get the correct number of columns from OUTPUT_HEADERS
num_columns = len(OUTPUT_HEADERS)
# Mock input Excel data with correct number of columns
mock_workbook = MagicMock()
mock_sheet = MagicMock()
mock_sheet.iter_rows.return_value = [
tuple(f"data{j}" for j in range(num_columns)), # Row 1
tuple(f"data{j+num_columns}" for j in range(num_columns)) # Row 2
]
mock_workbook.active = mock_sheet
mock_load_excel.return_value = mock_workbook
# Mock output workbook
mock_output_workbook = MagicMock()
mock_output_sheet = MagicMock()
mock_output_workbook.active = mock_output_sheet
mock_create_output.return_value = mock_output_workbook
# Mock unpacked input data to match the headers
mock_unpack.side_effect = lambda input_data: {key: f"unpacked_{value}" for key, value in input_data.items()}
# Mock API response
mock_api_request.return_value = ({"status": "success"}, 0.5)
# Run function
process_rows()
# Ensure rows were processed correctly
self.assertTrue(mock_output_sheet.append.called, "Output sheet should have data appended.")
mock_save_excel.assert_called_once()
if __name__ == "__main__":
unittest.main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment