From d22e37de7982986c2c22198501907964819b87b0 Mon Sep 17 00:00:00 2001 From: Giordon Stark Date: Thu, 8 Dec 2022 09:31:40 -0800 Subject: [PATCH] test upgrade 1.0.1 to itself --- tests/test_upgrade.py | 24 +++++++- tests/test_upgrade/patchset_1.0.1.json | 29 +++++++++ tests/test_upgrade/workspace_1.0.1.json | 82 +++++++++++++++++++++++++ 3 files changed, 133 insertions(+), 2 deletions(-) create mode 100644 tests/test_upgrade/patchset_1.0.1.json create mode 100644 tests/test_upgrade/workspace_1.0.1.json diff --git a/tests/test_upgrade.py b/tests/test_upgrade.py index 3c9524c4a6..01adef4305 100644 --- a/tests/test_upgrade.py +++ b/tests/test_upgrade.py @@ -20,7 +20,7 @@ def test_upgrade_to_latest(datadir): def test_1_0_0_workspace(datadir, caplog, monkeypatch): """ - Test upgrading a workspace from 1.0.0 + Test upgrading a workspace from 1.0.0 to 1.0.1 """ spec = json.load(open(datadir.joinpath("workspace_1.0.0.json"), encoding="utf-8")) @@ -37,7 +37,7 @@ def test_1_0_0_workspace(datadir, caplog, monkeypatch): def test_1_0_0_patchset(datadir, caplog, monkeypatch): """ - Test upgrading a patchset from 1.0.0 + Test upgrading a patchset from 1.0.0 to 1.0.1 """ spec = json.load(open(datadir.joinpath("patchset_1.0.0.json"), encoding="utf-8")) @@ -50,3 +50,23 @@ def test_1_0_0_patchset(datadir, caplog, monkeypatch): new_spec = pyhf.schema.upgrade(to_version='1.0.1').patchset(spec) assert new_spec['version'] == '1.0.1' + + +def test_1_0_1_workspace(datadir): + """ + Test upgrading a workspace from 1.0.1 to 1.0.1 + """ + spec = json.load(open(datadir.joinpath("workspace_1.0.1.json"), encoding="utf-8")) + + new_spec = pyhf.schema.upgrade(to_version='1.0.1').workspace(spec) + assert new_spec['version'] == '1.0.1' + + +def test_1_0_1_patchset(datadir): + """ + Test upgrading a patchset from 1.0.1 to 1.0.1 + """ + spec = json.load(open(datadir.joinpath("patchset_1.0.1.json"), encoding="utf-8")) + + new_spec = pyhf.schema.upgrade(to_version='1.0.1').patchset(spec) + assert new_spec['version'] == '1.0.1' diff --git a/tests/test_upgrade/patchset_1.0.1.json b/tests/test_upgrade/patchset_1.0.1.json new file mode 100644 index 0000000000..04dcee3b50 --- /dev/null +++ b/tests/test_upgrade/patchset_1.0.1.json @@ -0,0 +1,29 @@ +{ + "metadata": { + "references": { "hepdata": "ins1234567" }, + "description": "patchset for validation/xmlimport_input/config/example.xml", + "digests": { "sha256": "7c32ca3b8db75cbafcf5cd7ed4672fa2b1fa69e391c9b89068dd947a521866ec" }, + "labels": ["x"] + }, + "patches": [ + { + "metadata": { + "name": "patch_channel1_signal_syst1", + "values": [0] + }, + "patch": [ + { + "op": "replace", + "path": "/channels/0/samples/0/modifiers/0/data/hi", + "value": 1.2 + }, + { + "op": "replace", + "path": "/channels/0/samples/0/modifiers/0/data/lo", + "value": 0.8 + } + ] + } + ], + "version": "1.0.0" +} diff --git a/tests/test_upgrade/workspace_1.0.1.json b/tests/test_upgrade/workspace_1.0.1.json new file mode 100644 index 0000000000..bda01fa940 --- /dev/null +++ b/tests/test_upgrade/workspace_1.0.1.json @@ -0,0 +1,82 @@ +{ + "channels": [ + { + "name": "singlechannel", + "samples": [ + { + "data": [ + 5 + ], + "modifiers": [ + { + "data": null, + "name": "mu", + "type": "normfactor" + } + ], + "name": "signal" + }, + { + "data": [ + 50 + ], + "modifiers": [ + { + "data": [ + 6 + ], + "name": "uncorr_bkguncrt", + "type": "shapesys" + } + ], + "name": "background" + } + ] + } + ], + "measurements": [ + { + "config": { + "parameters": [ + { + "bounds": [ + [ + 0, + 10 + ] + ], + "fixed": false, + "inits": [ + 1 + ], + "name": "mu" + }, + { + "bounds": [ + [ + 1e-10, + 10 + ] + ], + "fixed": false, + "inits": [ + 1 + ], + "name": "uncorr_bkguncrt" + } + ], + "poi": "mu" + }, + "name": "measurement" + } + ], + "observations": [ + { + "data": [ + 50 + ], + "name": "singlechannel" + } + ], + "version": "1.0.0" +}