mirror of
https://github.com/clearlinux/autospec.git
synced 2026-08-24 16:57:48 +00:00
11569333b4
The complexity of the buildpattern has been significantly reduced with the move to a centralized specfiles class to handle specfile writes. This patch tests the remaining functionality and fixes a typo in buildpattern.py (pattern_strengh -> pattern_strength).
44 lines
1.2 KiB
Python
44 lines
1.2 KiB
Python
import unittest
|
|
import buildpattern
|
|
|
|
|
|
class TestBuildpattern(unittest.TestCase):
|
|
|
|
def setUp(self):
|
|
"""
|
|
Test setup method to reset the buildpattern module
|
|
"""
|
|
buildpattern.default_pattern = "make"
|
|
buildpattern.pattern_strength = 0
|
|
buildpattern.sources = {
|
|
"unit": [],
|
|
"gcov": [],
|
|
"tmpfile": [],
|
|
"archive": []
|
|
}
|
|
buildpattern.source_index = {}
|
|
buildpattern.archive_details = {}
|
|
|
|
def test_set_build_pattern(self):
|
|
"""
|
|
Test set_build_pattern with sufficient pattern strength
|
|
"""
|
|
buildpattern.set_build_pattern("configure_ac", 1)
|
|
self.assertEqual(buildpattern.default_pattern, "configure_ac")
|
|
self.assertEqual(buildpattern.pattern_strength, 1)
|
|
|
|
def test_set_build_pattern_low_strength(self):
|
|
"""
|
|
Test set_build_pattern with low pattern strength, nothing in the module
|
|
should change
|
|
"""
|
|
buildpattern.pattern_strength = 2
|
|
buildpattern.set_build_pattern("configure_ac", 1)
|
|
self.assertEqual(buildpattern.default_pattern, "make")
|
|
self.assertEqual(buildpattern.pattern_strength, 2)
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main(buffer=True)
|