From 926cddf95ff84f5ad1177bd4079b8aff2998b913 Mon Sep 17 00:00:00 2001 From: Clement Verna Date: Mar 26 2018 06:43:14 +0000 Subject: Update the unit tests Signed-off-by: Clement Verna --- diff --git a/pagure/hooks/pagure_ci.py b/pagure/hooks/pagure_ci.py index ecf15de..29d1a2a 100644 --- a/pagure/hooks/pagure_ci.py +++ b/pagure/hooks/pagure_ci.py @@ -102,12 +102,14 @@ class PagureCiForm(FlaskForm): ci_url = wtforms.TextField( 'URL to the project on the CI service', - [RequiredIf('active'), wtforms.validators.Length(max=255)], + [RequiredIf(['active_commit', 'active_pr']), + wtforms.validators.Length(max=255)], ) ci_job = wtforms.TextField( 'Name of the job to trigger', - [RequiredIf('active'), wtforms.validators.Length(max=255)], + [RequiredIf(['active_commit', 'active_pr']), + wtforms.validators.Length(max=255)], ) active = wtforms.BooleanField( diff --git a/tests/test_pagure_flask_ui_plugins_pagure_ci.py b/tests/test_pagure_flask_ui_plugins_pagure_ci.py index c628be1..6314f97 100644 --- a/tests/test_pagure_flask_ui_plugins_pagure_ci.py +++ b/tests/test_pagure_flask_ui_plugins_pagure_ci.py @@ -34,8 +34,11 @@ class PagureFlaskPluginPagureCItests(tests.SimplePagureTest): '', output.data) self.assertIn( - '', output.data) + '', output.data) + self.assertIn( + '', output.data) csrf_token = output.data.split( 'name="csrf_token" type="hidden" value="')[1].split('">')[0] @@ -55,12 +58,15 @@ class PagureFlaskPluginPagureCItests(tests.SimplePagureTest): '', output.data) self.assertIn( - '', output.data) + '', output.data) + self.assertIn( + '', output.data) # Activate hook data = { - 'active': 'y', + 'active_commit': 'y', 'ci_url': 'https://jenkins.fedoraproject.org', 'ci_type': 'jenkins', 'ci_job': 'test/job' @@ -80,8 +86,11 @@ class PagureFlaskPluginPagureCItests(tests.SimplePagureTest): '', output.data) self.assertIn( - '', output.data) + '', output.data) + self.assertIn( + '', output.data) data['csrf_token'] = csrf_token @@ -112,8 +121,8 @@ class PagureFlaskPluginPagureCItests(tests.SimplePagureTest): '', output.data) self.assertIn( - '', output.data) + '', output.data) self.assertIn( '
\nhttps://pagure.org/api/0/ci/jenkins/test/',
                 output.data)
@@ -145,11 +154,11 @@ class PagureFlaskPluginPagureCItests(tests.SimplePagureTest):
                 '', output.data)
             self.assertIn(
-                '', output.data)
+                '', output.data)
 
             # Missing the required ci_url
-            data = {'csrf_token': csrf_token, 'active': 'y'}
+            data = {'csrf_token': csrf_token, 'active_commit': 'y'}
 
             output = self.app.post(
                 '/test/settings/Pagure CI', data=data, follow_redirects=True)
@@ -169,8 +178,8 @@ class PagureFlaskPluginPagureCItests(tests.SimplePagureTest):
                 '\nThis field is required.',
                 output.data)
             self.assertIn(
-                '', output.data)
+                '', output.data)
 
     def test_plugin_pagure_ci_namespaced(self):
         """ Test the pagure ci plugin on/off endpoint. """
@@ -193,7 +202,7 @@ class PagureFlaskPluginPagureCItests(tests.SimplePagureTest):
                 '', output.data)
             self.assertIn(
-                '', output.data)
 
             csrf_token = output.data.split(
@@ -201,7 +210,7 @@ class PagureFlaskPluginPagureCItests(tests.SimplePagureTest):
 
             # Activate hook
             data = {
-                'active': 'y',
+                'active_pr': 'y',
                 'ci_url': 'https://jenkins.fedoraproject.org',
                 'ci_job': 'test/job',
                 'ci_type': 'jenkins',
@@ -235,7 +244,7 @@ class PagureFlaskPluginPagureCItests(tests.SimplePagureTest):
                 '', output.data)
             self.assertTrue(
-                '' in output.data)
             self.assertIn(
                 '
\nhttps://pagure.org/api/0/ci/jenkins/somenamespace/test3/',