fixed runing main

pull/231/head
Yariv Menachem 2024-12-11 16:38:45 +02:00
parent f4ebcc2d51
commit bf974467ab
3 changed files with 28 additions and 6 deletions

3
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,3 @@
{
"python.envFile": "${workspaceFolder}/.env"
}

View File

@ -1,4 +1,3 @@
from http import client
import os
from typing import List
from pymongo import MongoClient, UpdateOne
@ -13,7 +12,7 @@ class JobRepository:
# Connect to MongoDB server
self.client = MongoClient(self.mongoUri)
# Access a database (it will be created automatically if it doesn't exist)
self.db = client["jobs_database"]
self.db = self.client["jobs_database"]
# Access a collection
self.collection = self.db["jobs"]

View File

@ -2,7 +2,27 @@ from jobspy.db.job_repository import JobRepository
from tests.test_util import createMockJob
def insert_job():
jobRepository = JobRepository()
class DatabaseTests:
def __init__(self):
"""
This block ensures that the script runs the test only when executed directly,
not when imported as a module.
"""
self.jobRepository = JobRepository()
def insert_job(self):
"""
Inserts a mock job into the database using JobRepository.
"""
job = createMockJob()
jobRepository.insert_or_update_job(job)
self.jobRepository.insert_or_update_job(job)
print("Job inserted successfully.")
if __name__ == '__main__':
# Create an instance of DatabaseTests
tests = DatabaseTests()
# Run the insert_job test
tests.insert_job()