Skip to content

Commit

Permalink
Update add_analyses test
Browse files Browse the repository at this point in the history
Adds NUISANCE to test_add_analyses and fix files used for other file types.
  • Loading branch information
ItIsJordan committed Dec 4, 2024
1 parent c42f828 commit c7fd52e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
25 changes: 20 additions & 5 deletions tests/search_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,13 +433,14 @@ def test_add_analyses(app):
test_data = [
{ # ProSelecta/NUISANCE
"type": "NUISANCE",
"filename": "test.cxx"
"filename": "test.ProSelecta"
},
{ # HistFactory entry
"type": "HistFactory",
"filename": "test.cxx"
}
"filename": "test.tar.gz"
},
]
# This should probably be changed to use SITE_URL or some similar concept
analysis_url = "http://localhost:5000/record/resource/%s?landing_page=true"

with app.app_context():
Expand All @@ -465,15 +466,29 @@ def test_add_analyses(app):
# No errors should happen
assert not errors

# Add MadAnalysis DataResource object separately
mad_analysis = DataResource(
file_location = "placeholder",
file_type = "MadAnalysis",
file_description = "placeholder"
)

# Adding object to database
hepsubmission.resources.append(mad_analysis)
db.session.add(mad_analysis)
db.session.add(hepsubmission)

# Set up a generic doc object to match what add_analyses expects
test_doc = {"analyses": [], "recid": hepsubmission.publication_recid}
# Run the test add_analyses function
add_analyses(test_doc)

# A sorted list of all DataResource object IDs from subm,ission
# A sorted list of all DataResource object IDs from submission
data_ids = sorted([r.id for r in hepsubmission.resources])

assert len(data_ids) == len(test_doc["analyses"]) == len(test_data)
# There should be 3 analyses and 3 resources
assert len(data_ids) == len(test_doc["analyses"]) == 3

# There should be one entry into test_data per resource ID
# Looping through the test, resource IDs and the analysis outputs
for test, d_id, analysis in zip(test_data, data_ids, test_doc["analyses"]):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_data/test_analysis_submission/submission.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
description: "TestSubmission1-V1"
comment: TestComment1-V1
additional_resources:
- {description: Test, location: test.cxx, type: ProSelecta }
- {description: Test, location: test.cxx, type: HistFactory }
- {description: Test, location: test.ProSelecta, type: ProSelecta }
- {description: Test, location: test.tar.gz, type: HistFactory }
---
name: "TestTable1-V1"
description: TestTable1-description-V1
Expand Down
Empty file.

0 comments on commit c7fd52e

Please sign in to comment.