|
| 1 | +# SPDX-License-Identifier: Apache-2.0 |
| 2 | +# |
| 3 | +# http://nexb.com and https://github.com/nexB/scancode.io |
| 4 | +# The ScanCode.io software is licensed under the Apache License version 2.0. |
| 5 | +# Data generated with ScanCode.io is provided as-is without warranties. |
| 6 | +# ScanCode is a trademark of nexB Inc. |
| 7 | +# |
| 8 | +# You may not use this software except in compliance with the License. |
| 9 | +# You may obtain a copy of the License at: http://apache.org/licenses/LICENSE-2.0 |
| 10 | +# Unless required by applicable law or agreed to in writing, software distributed |
| 11 | +# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR |
| 12 | +# CONDITIONS OF ANY KIND, either express or implied. See the License for the |
| 13 | +# specific language governing permissions and limitations under the License. |
| 14 | +# |
| 15 | +# Data Generated with ScanCode.io is provided on an "AS IS" BASIS, WITHOUT WARRANTIES |
| 16 | +# OR CONDITIONS OF ANY KIND, either express or implied. No content created from |
| 17 | +# ScanCode.io should be considered or used as legal advice. Consult an Attorney |
| 18 | +# for any legal advice. |
| 19 | +# |
| 20 | +# ScanCode.io is a free software code scanning tool from nexB Inc. and others. |
| 21 | +# Visit https://github.com/nexB/scancode.io for support and download. |
| 22 | + |
| 23 | +from django.test import TestCase |
| 24 | + |
| 25 | +from scanpipe.models import CodebaseResource |
| 26 | +from scanpipe.models import Project |
| 27 | +from scanpipe.pipes import tag |
| 28 | + |
| 29 | + |
| 30 | +class ScanPipeTagPipesTest(TestCase): |
| 31 | + def setUp(self): |
| 32 | + self.project1 = Project.objects.create(name="Analysis") |
| 33 | + self.resource1 = CodebaseResource.objects.create( |
| 34 | + project=self.project1, path="dir/" |
| 35 | + ) |
| 36 | + self.resource2 = CodebaseResource.objects.create( |
| 37 | + project=self.project1, |
| 38 | + type=CodebaseResource.Type.FILE, |
| 39 | + path="dir/filename.ext", |
| 40 | + name="filename.ext", |
| 41 | + extension=".ext", |
| 42 | + ) |
| 43 | + |
| 44 | + def test_scanpipe_pipes_tag_tag_empty_codebase_resources(self): |
| 45 | + tag.tag_empty_codebase_resources(self.project1) |
| 46 | + self.resource1.refresh_from_db() |
| 47 | + self.resource2.refresh_from_db() |
| 48 | + self.assertEqual("", self.resource1.status) |
| 49 | + self.assertEqual("ignored-empty-file", self.resource2.status) |
| 50 | + |
| 51 | + def test_scanpipe_pipes_tag_tag_ignored_filenames(self): |
| 52 | + tag.tag_ignored_filenames(self.project1, filenames=[self.resource2.name]) |
| 53 | + self.resource1.refresh_from_db() |
| 54 | + self.resource2.refresh_from_db() |
| 55 | + self.assertEqual("", self.resource1.status) |
| 56 | + self.assertEqual("ignored-filename", self.resource2.status) |
| 57 | + |
| 58 | + def test_scanpipe_pipes_tag_tag_ignored_extensions(self): |
| 59 | + tag.tag_ignored_extensions(self.project1, extensions=[self.resource2.extension]) |
| 60 | + self.resource1.refresh_from_db() |
| 61 | + self.resource2.refresh_from_db() |
| 62 | + self.assertEqual("", self.resource1.status) |
| 63 | + self.assertEqual("ignored-extension", self.resource2.status) |
0 commit comments