Coverage for tests/utils.py: 100%
8 statements
« prev ^ index » next coverage.py v7.3.2, created at 2023-11-10 22:16 +0000
« prev ^ index » next coverage.py v7.3.2, created at 2023-11-10 22:16 +0000
1# This file is part of summit_utils.
2#
3# Developed for the LSST Data Management System.
4# This product includes software developed by the LSST Project
5# (https://www.lsst.org).
6# See the COPYRIGHT file at the top-level directory of this distribution
7# for details of code ownership.
8#
9# This program is free software: you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation, either version 3 of the License, or
12# (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with this program. If not, see <https://www.gnu.org/licenses/>.
22import os
23import vcr
25__all__ = (
26 "getVcr",
27)
30def getVcr():
31 """Get a VCR object for use in tests.
33 Use record_mode="none" to run tests for normal operation. To update files
34 or generate new ones, make sure you have a working connection to the EFD at
35 all the relevant sites, and temporarily run with mode="all" via *both*
36 python/pytest *and* with scons, as these generate slightly different HTTP
37 requests for some reason. Also make sure to do all this at both the summit
38 and USDF. The TTS is explicitly skipped and does not need to follow this
39 procedure.
40 """
41 dirname = os.path.dirname(__file__)
42 cassette_library_dir = os.path.join(dirname, "data", "cassettes")
43 safe_vcr = vcr.VCR(
44 record_mode="none",
45 cassette_library_dir=cassette_library_dir,
46 path_transformer=vcr.VCR.ensure_suffix(".yaml"),
47 match_on=['method', 'scheme', 'host', 'port', 'path', 'query', 'body']
48 )
49 return safe_vcr