The library is imported if available, but we never build it in any environment where the package would be installed. It was last used for RHEL 6 builds. Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com> (cherry picked from commit d95d1f59e2ae243ea794c5f5613fef3249b4fad6)
		
			
				
	
	
		
			41 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			41 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
| # -*- coding: utf-8 -*-
 | |
| 
 | |
| import argparse
 | |
| import unittest
 | |
| 
 | |
| from parameterized import parameterized
 | |
| 
 | |
| from pungi_utils import config_utils
 | |
| 
 | |
| 
 | |
| class TestDefineHelpers(unittest.TestCase):
 | |
|     @parameterized.expand(
 | |
|         [
 | |
|             ([], {}),
 | |
|             (["foo=bar", "baz=quux"], {"foo": "bar", "baz": "quux"}),
 | |
|             (["foo="], {"foo": ""}),
 | |
|             (["foo==bar"], {"foo": "=bar"}),
 | |
|         ]
 | |
|     )
 | |
|     def test_extract_defines(self, input, expected):
 | |
|         self.assertEqual(config_utils.extract_defines(input), expected)
 | |
| 
 | |
|     @parameterized.expand(["foo=bar", "foo=", "foo==bar"])
 | |
|     def test_validate_define_correct(self, value):
 | |
|         self.assertEqual(config_utils.validate_definition(value), value)
 | |
| 
 | |
|     @parameterized.expand(["foo", "=", "=foo", "1=2"])
 | |
|     def test_validate_define_incorrect(self, value):
 | |
|         with self.assertRaises(argparse.ArgumentTypeError):
 | |
|             config_utils.validate_definition(value)
 | |
| 
 | |
|     def test_remove_unknown(self):
 | |
|         conf = {"foo": "bar"}
 | |
|         config_utils.remove_unknown(conf, ["foo"])
 | |
|         self.assertEqual(conf, {})
 | |
| 
 | |
|     def test_remove_known(self):
 | |
|         conf = {"release_name": "bar"}
 | |
|         config_utils.remove_unknown(conf, ["release_name"])
 | |
|         self.assertEqual(conf, {"release_name": "bar"})
 |