def test_unicode_does_not_barf(self, monkeypatch): class FakeConn(object): def get_node_config(self, node_name): str(node_name) return '<slave></slave>' monkeypatch.setattr('mita.util.jenkins_connection', lambda: FakeConn()) name = u'\u2018vagrant\u2019' result = util.get_node_labels(name) assert result == []
def test_get_correct_node_labels(self): xml_string = """<?xml version="1.0" encoding="UTF-8"?> <slave> <name>centos7+158.69.77.220</name> <description></description> <remoteFS>/home/jenkins-build/build</remoteFS> <numExecutors>1</numExecutors> <mode>NORMAL</mode> <retentionStrategy class="hudson.slaves.RetentionStrategy$Always"/> <launcher class="hudson.plugins.sshslaves.SSHLauncher" plugin="[email protected]"> <host>158.69.77.220</host> <port>22</port> <credentialsId>39fa150b-b2a1-416e-b334-29a9a2c0b32d</credentialsId> <maxNumRetries>0</maxNumRetries> <retryWaitTime>0</retryWaitTime> </launcher> <label>amd64 centos7 x86_64 huge</label> <nodeProperties/> <userId>prado</userId> </slave> """ result = util.get_node_labels('trusty', _xml_configuration=xml_string) assert result == ['amd64', 'centos7', 'x86_64', 'huge']
def test_get_no_node_labels(self): result = util.get_node_labels('trusty', _xml_configuration='<slave></slave>') assert result == []