Skip to content

Commit

Permalink
Use SlurmParser objects in mongo_update unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
soline-b committed Nov 7, 2023

Verified

This commit was signed with the committer’s verified signature. The key has expired.
renovate-bot Mend Renovate
1 parent 737de29 commit 279dca0
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions slurm_state_test/test_mongo_update.py
Original file line number Diff line number Diff line change
@@ -2,20 +2,20 @@
from slurm_state.mongo_client import get_mongo_client
from slurm_state.config import get_config

from datetime import datetime
from slurm_state.sinfo_parser import node_parser
from slurm_state.sacct_parser import job_parser
# Import jobs and nodes parsers
from slurm_state.parsers.job_parser import JobParser
from slurm_state.parsers.node_parser import NodeParser

# Common imports
from datetime import datetime
import pytest
import pprint


def test_fetch_slurm_report_jobs():
res = list(
fetch_slurm_report(
job_parser,
"cedar",
"slurm_state_test/files/sacct_1",
JobParser("cedar", slurm_version="23.02.6"), # parser
"slurm_state_test/files/sacct_1", # report path
)
)

@@ -90,8 +90,7 @@ def test_fetch_slurm_report_jobs():
def test_fetch_slurm_report_nodes():
res = list(
fetch_slurm_report(
node_parser,
"mila",
NodeParser("mila", slurm_version="22.05.9"),
"slurm_state_test/files/sinfo_1",
)
)
@@ -229,13 +228,23 @@ def test_main_read_jobs_and_update_collection():
db.drop_collection("test_jobs")

main_read_report_and_update_collection(
"jobs", db.test_jobs, db.test_users, "cedar", "slurm_state_test/files/sacct_1"
"jobs",
db.test_jobs,
db.test_users,
"cedar",
"slurm_state_test/files/sacct_1",
from_file=True,
)

assert db.test_jobs.count_documents({}) == 2

main_read_report_and_update_collection(
"jobs", db.test_jobs, db.test_users, "cedar", "slurm_state_test/files/sacct_2"
"jobs",
db.test_jobs,
db.test_users,
"cedar",
"slurm_state_test/files/sacct_2",
from_file=True,
)

assert db.test_jobs.count_documents({}) == 3
@@ -255,6 +264,7 @@ def test_main_read_nodes_and_update_collection():
None,
"mila",
"slurm_state_test/files/sinfo_1",
from_file=True,
)

assert db.test_nodes.count_documents({}) == 2
@@ -265,6 +275,7 @@ def test_main_read_nodes_and_update_collection():
None,
"mila",
"slurm_state_test/files/sinfo_2",
from_file=True,
)

assert db.test_nodes.count_documents({}) == 3

0 comments on commit 279dca0

Please sign in to comment.