File tree Expand file tree Collapse file tree 3 files changed +28
-2
lines changed
snippets/instances/create_start_instance Expand file tree Collapse file tree 3 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -90,6 +90,7 @@ def __repr__(self):
9090 re .compile (r".*requirements-test\.txt$" ),
9191 re .compile (r".*?/tests/.*" ),
9292 re .compile (r".*?/__pycache__/.*" ),
93+ re .compile (r".*?sponge_log.xml.*" ),
9394)
9495
9596
Original file line number Diff line number Diff line change 3030
3131def get_disk (project_id : str , zone : str , disk_name : str ) -> compute_v1 .Disk :
3232 """
33- Deletes a disk from a project.
33+ Gets a disk from a project.
3434
3535 Args:
3636 project_id: project ID or project number of the Cloud project you want to use.
37- zone: name of the zone in which is the disk you want to delete .
37+ zone: name of the zone where the disk exists .
3838 disk_name: name of the disk you want to retrieve.
3939 """
4040 disk_client = compute_v1 .DisksClient ()
Original file line number Diff line number Diff line change 1616from pathlib import Path
1717import tempfile
1818
19+ import pytest
20+
1921from . import sgs
2022
2123FIXTURE_INGREDIENTS = Path ("sgs_test_fixtures/ingredients" )
@@ -30,3 +32,26 @@ def test_sgs_generate():
3032 for test_file in map (Path , glob .glob (f"{ tmp_dir } /**" )):
3133 match_file = FIXTURE_OUTPUT / test_file .relative_to (tmp_dir )
3234 assert test_file .read_bytes () == match_file .read_bytes ()
35+
36+
37+ def test_snippets_freshness ():
38+ """
39+ Make sure that the snippets/ folder is up-to-date and matches
40+ ingredients/ and recipes/. This test will generate SGS output
41+ in a temporary directory and compare it to the content of
42+ snippets/ folder.
43+ """
44+ with tempfile .TemporaryDirectory () as tmp_dir :
45+ args = Namespace (output_dir = tmp_dir )
46+ sgs .generate (args , Path ("ingredients/" ).absolute (), Path ("recipes/" ).absolute ())
47+ print (list (map (Path , glob .glob (f"{ tmp_dir } /**" ))))
48+ for test_file in map (Path , glob .glob (f"{ tmp_dir } /**" , recursive = True )):
49+ match_file = Path ("snippets/" ) / test_file .relative_to (tmp_dir )
50+ if test_file .is_file ():
51+ if test_file .read_bytes () != match_file .read_bytes ():
52+ pytest .fail (
53+ f"This test fails because file { match_file } seems to be outdated. Please run "
54+ f"`python sgs.py generate` to update your snippets."
55+ )
56+ elif test_file .is_dir ():
57+ assert match_file .is_dir ()
You can’t perform that action at this time.
0 commit comments