Check that Pegleg only considers YAML

Add a unit test to make sure Pegleg only considers YAML files
when linting

Fixes a typo in filename for test_selectable_linting

Changed site_yaml file stucture to more resemble real site
directory structure

Change-Id: Ib1520f9509d279d88b4408858878022fb05c7707
This commit is contained in:
Krysta 2018-04-09 13:42:51 -05:00
parent 6072a5e13d
commit 994a13c1ca
3 changed files with 30 additions and 0 deletions

View File

@ -0,0 +1,30 @@
# Copyright 2018 AT&T Intellectual Property. All other rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import tempfile
from pegleg import config
from pegleg.engine.util import files
def test_no_non_yamls(tmpdir):
p = tmpdir.mkdir("site_yamls").mkdir("global")
for x in range(3): # Create 3 YAML files
p.join("good-%d.yaml" % x).write('fake-content')
p.join("bad.txt").write("fake-content")
config.set_primary_repo(str(tmpdir.listdir()[0]))
results = list(files.all())
assert 3 == len(results)
# make sure only YAML files are returned
for i in results:
assert i.endswith('.yaml')