mirror of https://github.com/Bunsly/JobSpy
fixed runing main
parent
f4ebcc2d51
commit
bf974467ab
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"python.envFile": "${workspaceFolder}/.env"
|
||||
}
|
|
@ -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"]
|
||||
|
||||
|
|
|
@ -2,7 +2,27 @@ from jobspy.db.job_repository import JobRepository
|
|||
from tests.test_util import createMockJob
|
||||
|
||||
|
||||
def insert_job():
|
||||
jobRepository = JobRepository()
|
||||
job = createMockJob()
|
||||
jobRepository.insert_or_update_job(job)
|
||||
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()
|
||||
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()
|
||||
|
|
Loading…
Reference in New Issue