Merge "Ensure tests run with ConfigParser object"
This commit is contained in:
commit
6fd8c4ec0e
@ -36,6 +36,8 @@ try:
|
||||
from unittest import mock
|
||||
except ImportError:
|
||||
import mock # noqa
|
||||
|
||||
from jenkins_jobs.cmd import DEFAULT_CONF
|
||||
import jenkins_jobs.local_yaml as yaml
|
||||
from jenkins_jobs.parser import YamlParser
|
||||
from jenkins_jobs.xml_config import XmlJob
|
||||
@ -119,15 +121,19 @@ class BaseTestCase(object):
|
||||
yaml_content = yaml.load(yaml_file)
|
||||
return yaml_content
|
||||
|
||||
def _get_config(self):
|
||||
config = configparser.ConfigParser()
|
||||
config.readfp(StringIO(DEFAULT_CONF))
|
||||
if self.conf_filename is not None:
|
||||
with io.open(self.conf_filename, 'r', encoding='utf-8') as cf:
|
||||
config.readfp(cf)
|
||||
return config
|
||||
|
||||
def test_yaml_snippet(self):
|
||||
if not self.in_filename:
|
||||
return
|
||||
|
||||
if self.conf_filename is not None:
|
||||
config = configparser.ConfigParser()
|
||||
config.readfp(io.open(self.conf_filename, 'r', encoding='utf-8'))
|
||||
else:
|
||||
config = {}
|
||||
config = self._get_config()
|
||||
|
||||
expected_xml = self._read_utf8_content()
|
||||
yaml_content = self._read_yaml_content(self.in_filename)
|
||||
@ -178,13 +184,10 @@ class BaseTestCase(object):
|
||||
|
||||
class SingleJobTestCase(BaseTestCase):
|
||||
def test_yaml_snippet(self):
|
||||
config = self._get_config()
|
||||
|
||||
expected_xml = self._read_utf8_content()
|
||||
|
||||
if self.conf_filename:
|
||||
config = configparser.ConfigParser()
|
||||
config.readfp(io.open(self.conf_filename, 'r', encoding='utf-8'))
|
||||
else:
|
||||
config = None
|
||||
parser = YamlParser(config)
|
||||
parser.parse(self.in_filename)
|
||||
|
||||
|
5
tests/hipchat/fixtures/hipchat001.conf
Normal file
5
tests/hipchat/fixtures/hipchat001.conf
Normal file
@ -0,0 +1,5 @@
|
||||
[hipchat]
|
||||
authtoken=blue
|
||||
send-as=Jenkins
|
||||
[jenkins]
|
||||
url=green
|
@ -14,8 +14,8 @@
|
||||
</properties>
|
||||
<publishers>
|
||||
<jenkins.plugins.hipchat.HipChatNotifier>
|
||||
<jenkinsUrl>url</jenkinsUrl>
|
||||
<authToken>authtoken</authToken>
|
||||
<jenkinsUrl>green</jenkinsUrl>
|
||||
<authToken>blue</authToken>
|
||||
<room/>
|
||||
</jenkins.plugins.hipchat.HipChatNotifier>
|
||||
</publishers>
|
||||
|
5
tests/hipchat/fixtures/hipchat002.conf
Normal file
5
tests/hipchat/fixtures/hipchat002.conf
Normal file
@ -0,0 +1,5 @@
|
||||
[hipchat]
|
||||
authtoken=blue
|
||||
send-as=Jenkins
|
||||
[jenkins]
|
||||
url=green
|
@ -8,8 +8,8 @@
|
||||
</properties>
|
||||
<publishers>
|
||||
<jenkins.plugins.hipchat.HipChatNotifier>
|
||||
<jenkinsUrl>url</jenkinsUrl>
|
||||
<authToken>authtoken</authToken>
|
||||
<jenkinsUrl>green</jenkinsUrl>
|
||||
<authToken>blue</authToken>
|
||||
<room/>
|
||||
</jenkins.plugins.hipchat.HipChatNotifier>
|
||||
</publishers>
|
||||
|
@ -14,9 +14,9 @@
|
||||
</properties>
|
||||
<publishers>
|
||||
<jenkins.plugins.hipchat.HipChatNotifier>
|
||||
<buildServerUrl>url</buildServerUrl>
|
||||
<sendAs>send-as</sendAs>
|
||||
<authToken>authtoken</authToken>
|
||||
<buildServerUrl>http://localhost:8080/</buildServerUrl>
|
||||
<sendAs>Jenkins</sendAs>
|
||||
<authToken>dummy</authToken>
|
||||
<room/>
|
||||
</jenkins.plugins.hipchat.HipChatNotifier>
|
||||
</publishers>
|
||||
|
@ -14,9 +14,9 @@
|
||||
</properties>
|
||||
<publishers>
|
||||
<jenkins.plugins.hipchat.HipChatNotifier>
|
||||
<buildServerUrl>url</buildServerUrl>
|
||||
<sendAs>send-as</sendAs>
|
||||
<authToken>authtoken</authToken>
|
||||
<buildServerUrl>http://localhost:8080/</buildServerUrl>
|
||||
<sendAs>Jenkins</sendAs>
|
||||
<authToken>dummy</authToken>
|
||||
<room/>
|
||||
</jenkins.plugins.hipchat.HipChatNotifier>
|
||||
</publishers>
|
||||
|
Loading…
Reference in New Issue
Block a user