test_DVAppOptions.py 1.98 KB
Newer Older
Maurizio Martinelli's avatar
Maurizio Martinelli committed
1
2
3
4
5
6
7
8
9
10
11
###############################################################################
# (c) Copyright 2021 CERN for the benefit of the LHCb Collaboration           #
#                                                                             #
# This software is distributed under the terms of the GNU General Public      #
# Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING".   #
#                                                                             #
# In applying this licence, CERN does not waive the privileges and immunities #
# granted to it by virtue of its status as an Intergovernmental Organization  #
# or submit itself to any jurisdiction.                                       #
###############################################################################

12
import pytest
Maurizio Martinelli's avatar
Maurizio Martinelli committed
13

14
from DaVinci import options
Maurizio Martinelli's avatar
Maurizio Martinelli committed
15

16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

def test_option_set():
    print(options.detectors)


def test_option_unset():
    with pytest.raises(AttributeError):
        print(options.evt_max)


def test_option_get_after_set():
    options.evt_max = 1
    print(options.evt_max)


def test_option_unknown():
    with pytest.raises(AttributeError):
        print(options.unknown)
34

Gitlab CI's avatar
Gitlab CI committed
35

Davide Fazzini's avatar
Davide Fazzini committed
36
def test_ApplicationOptions_consistency_with_PyConf():
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
    """
    Check for any difference between the options available in ApplicationOptions in PyConf and the DV options.
    """
    from PyConf.application import ApplicationOptions
    from DaVinci import options
    from DaVinci.options_default import __optsDict__ as dv_defaults

    lhcb_options = ApplicationOptions.getDefaultProperties()
    dv_options = options.getDefaultProperties()

    for name, _ in lhcb_options.items():
        # Exclude Moore-specific options since they will be moved into a
        # dedicated Moore-specific ApplicationOptions class.
        if name not in ["lines_maker", "tck"]:
            assert name in dv_options, f"Option {name} not available in DaVinci"
            assert name in dv_defaults, f"Option {name} doesn't have a default value in DaVinci"