Coverage for tests/utils.py: 100%
8 statements
« prev ^ index » next coverage.py v7.5.1, created at 2024-05-15 03:27 -0700
« prev ^ index » next coverage.py v7.5.1, created at 2024-05-15 03:27 -0700
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
24import vcr
26__all__ = ("getVcr",)
29def getVcr():
30 """Get a VCR object for use in tests.
32 Use record_mode="none" to run tests for normal operation. To update files
33 or generate new ones, make sure you have a working connection to the EFD at
34 all the relevant sites, and temporarily run with mode="all" via *both*
35 python/pytest *and* with scons, as these generate slightly different HTTP
36 requests for some reason. Also make sure to do all this at both the summit
37 and USDF. The TTS is explicitly skipped and does not need to follow this
38 procedure.
39 """
40 dirname = os.path.dirname(__file__)
41 cassette_library_dir = os.path.join(dirname, "data", "cassettes")
42 safe_vcr = vcr.VCR(
43 record_mode="none",
44 cassette_library_dir=cassette_library_dir,
45 path_transformer=vcr.VCR.ensure_suffix(".yaml"),
46 match_on=["method", "scheme", "host", "port", "path", "query", "body"],
47 )
48 return safe_vcr