Coverage for tests / utils.py: 100%

8 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-05-07 09:02 +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/>. 

21 

22import os 

23 

24import vcr 

25 

26__all__ = ("getVcr",) 

27 

28 

29def getVcr(): 

30 """Get a VCR object for use in tests. 

31 

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 

34 and temporarily run with mode="all" via *both* python/pytest *and* with 

35 scons, as these generate slightly different HTTP requests for some reason. 

36 Also make sure to do this at the summit (USDF coverage is provided by the 

37 same recording, since matching ignores host/port and so is independent of 

38 whether requests go through a proxy). The TTS is explicitly skipped and 

39 does not need to follow this 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", "path", "query", "body"], 

48 ) 

49 return safe_vcr