#1058 Add 'target' policy
Merged 2 years ago by tkopecek. Opened 3 years ago by tkopecek.
tkopecek/koji issue1040  into  master

@@ -204,6 +204,9 @@ 

      * for untag operations, tests the tag the build is being removed from

      * only applicable to the tag policy

  

+ ``target``

+     * matches against the build's target name. Accepts glob patterns.

+ 

  ``hastag``

      * checks the current tags for the build in question against the arguments.

  

file modified
+12
@@ -137,6 +137,18 @@ 

          return False

  

  

+ class TargetTest(MatchTest):

+     """Matches target in the data against glob patterns

+ 

+     True if any of the expressions match, else False

+ 

+     Syntax:

+         target pattern1 [pattern2 ...]

+     """

+     name = 'target'

+     field = 'target'

+ 

+ 

  class CompareTest(BaseSimpleTest):

      """Simple numeric field comparison

  

@@ -69,6 +69,14 @@ 

          self.assertTrue(obj.run({'thing': 'elseplus'}))

          self.assertFalse(obj.run({}))

  

+     def test_target_test(self):

+         obj = koji.policy.TargetTest('target valid')

+         self.assertTrue(obj.run({'target': 'valid'}))

+         self.assertFalse(obj.run({'target': 'else'}))

+         obj = koji.policy.TargetTest('target valid else*')

+         self.assertTrue(obj.run({'target': 'valid'}))

+         self.assertTrue(obj.run({'target': 'elseplus'}))

+ 

      def test_compare_test(self):

          obj = koji.policy.CompareTest('compare thing > 2')

          self.assertFalse(obj.run({'thing': 1}))
@@ -120,6 +128,7 @@ 

              'has': koji.policy.HasTest,

              'match': koji.policy.MatchTest,

              'none': koji.policy.NoneTest,

+             'target': koji.policy.TargetTest,

              'true': koji.policy.TrueTest,

          }

          self.assertDictEqual(expected, actual)

Fixes: https://pagure.io/koji/issue/1040

  • moved policy tests to standard set (not py2-only)

rebased onto a642cdf

2 years ago

Metadata Update from @tkopecek:
- Pull-request tagged with: testing-ready

2 years ago

Metadata Update from @jcupova:
- Pull-request tagged with: testing-done

2 years ago

Commit 5ad5261 fixes this pull-request

Pull-Request has been merged by tkopecek

2 years ago