Skip to content

Commit

Permalink
updated yml
Browse files Browse the repository at this point in the history
  • Loading branch information
ajits-github committed Sep 5, 2023
1 parent 3ec68a6 commit 11a9c41
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 17 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@ jobs:
with:
python-version: 3.7

- name: Set PYTHONPATH
run: echo "PYTHONPATH=$PWD" >> $GITHUB_ENV

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run tests with pytest
run: pytest
run: pytest tests\test_api.py

# build-and-deploy:
# needs: test
Expand Down
22 changes: 16 additions & 6 deletions tests/test_api.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
import requests

BASE_URL = "http://127.0.0.1:8000"
# BASE_URL = "http://127.0.0.1:8000"

def test_get_parts():
manufacturer_name = "Ammann"
response = requests.get(f"{BASE_URL}/parts/?manufacturer={manufacturer_name}")
# def test_get_parts():
# manufacturer_name = "Ammann"
# response = requests.get(f"{BASE_URL}/parts/?manufacturer={manufacturer_name}")

assert response.status_code == 200
# Further checks can be added based on expected response content
# assert response.status_code == 200
# # Further checks can be added based on expected response content


from fastapi.testclient import TestClient
from api.api_server import app

client = TestClient(app)

def test_get_parts():
response = client.get("/parts/?manufacturer=Ammann")
assert response.status_code == 200
24 changes: 14 additions & 10 deletions tests/test_database.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
import sqlite3
from database.db_manager import initialize_database, store_to_db

def test_initialize_database():
# Assuming that you have a function to check if the table exists
assert initialize_database() == True
from config_util import config

DB_PATH = config['database']['path']

# def test_initialize_database():
# # Function to check if the table exists
# assert initialize_database() == True

def test_store_and_retrieve_data():
sample_data = [{
'manufacturer': 'Test Manufacturer',
'category': 'Test Category',
'model': 'Test Model',
'part_number': '12345',
'part_category': 'Test Part Category'
'manufacturer': 'Ammann',
'category': 'Ammann',
'model': 'Roller Parts',
'part_number': 'ND011710',
'part_category': 'LEFT COVER'
}]

store_to_db(sample_data)

# Logic to fetch data from DB to verify it's been inserted
conn = sqlite3.connect('your_database_name.db')
conn = sqlite3.connect(DB_PATH)
cursor = conn.cursor()
cursor.execute("SELECT * FROM your_table_name WHERE manufacturer=?", ('Test Manufacturer',))
cursor.execute("SELECT * FROM parts_data WHERE manufacturer=?", ('Ammann',))
data = cursor.fetchone()
conn.close()

Expand Down

0 comments on commit 11a9c41

Please sign in to comment.