示例#1
0
 def test_get_full_url(self, monkeypatch):
     bp = BuildPtr(
         job_name='j3', job_url='u3', build_id=5, build_url='/u3/5'
     )
     url = bp.get_full_url(jenkins_url='http://jenkins.example.com')
     assert 'http://jenkins.example.com/u3/5' == url
     monkeypatch.setenv('JENKINS_URL', 'http://jenkins.example.org')
     url = bp.get_full_url()
     assert 'http://jenkins.example.org/u3/5' == url
     monkeypatch.delenv('JENKINS_URL', raising=False)
     with pytest.raises(NotInJenkins):
         bp.get_full_url()
示例#2
0
 def test_init(self):
     assert BuildsList() == []
     data = [
         BuildPtr(job_name='j1', job_url='u1', queue_id=1),
         BuildPtr(job_name='j2', job_url='u2', build_id=2, build_url='bu2'),
     ]
     bl = BuildsList(data)
     assert bl == data
     data = [
         BuildPtr(job_name='j1', job_url='u1', queue_id=1),
         dict(job_name='j2', job_url='u2', build_id=2, build_url='bu2'),
     ]
     with pytest.raises(TypeError):
         BuildsList(data)
示例#3
0
 def test_from_currnt_build_env(self, monkeypatch):
     monkeypatch.setenv('JENKINS_URL', 'http://jenkins.example.com')
     monkeypatch.setenv('JOB_BASE_NAME', 'j1')
     monkeypatch.setenv('JOB_URL', 'http://jenkins.example.com/job/j1')
     monkeypatch.setenv('BUILD_ID', '7')
     monkeypatch.setenv('BUILD_URL', 'http://jenkins.example.com/job/j1/7')
     bp = BuildPtr.from_currnt_build_env()
     assert bp.job_name == 'j1'
     assert bp.job_url == 'http://jenkins.example.com/job/j1'
     assert bp.build_id == '7'
     assert bp.build_url == '/job/j1/7'
示例#4
0
 def test_from_currnt_build_env(self, monkeypatch):
     monkeypatch.setenv('JENKINS_URL', 'http://jenkins.example.com')
     monkeypatch.setenv('JOB_BASE_NAME', 'j1')
     monkeypatch.setenv('JOB_URL', 'http://jenkins.example.com/job/j1')
     monkeypatch.setenv('BUILD_ID', '7')
     monkeypatch.setenv('BUILD_URL', 'http://jenkins.example.com/job/j1/7')
     bl = BuildsList.from_currnt_build_env()
     bp = BuildPtr.from_currnt_build_env()
     assert len(bl) == 1
     assert id(bl[0]) != id(bp)
     assert bl[0] == bp
 def test_from_currnt_build_env(self, monkeypatch):
     monkeypatch.setenv('JENKINS_URL', 'http://jenkins.example.com')
     monkeypatch.setenv('JOB_BASE_NAME', 'j1')
     monkeypatch.setenv('JOB_URL', 'http://jenkins.example.com/job/j1')
     monkeypatch.setenv('BUILD_ID', '7')
     monkeypatch.setenv('BUILD_URL', 'http://jenkins.example.com/job/j1/7')
     bp = BuildPtr.from_currnt_build_env()
     assert bp.job_name == 'j1'
     assert bp.job_url == 'http://jenkins.example.com/job/j1'
     assert bp.build_id == '7'
     assert bp.build_url == '/job/j1/7'
 def test_from_currnt_build_env(self, monkeypatch):
     monkeypatch.setenv('JENKINS_URL', 'http://jenkins.example.com')
     monkeypatch.setenv('JOB_BASE_NAME', 'j1')
     monkeypatch.setenv('JOB_URL', 'http://jenkins.example.com/job/j1')
     monkeypatch.setenv('BUILD_ID', '7')
     monkeypatch.setenv('BUILD_URL', 'http://jenkins.example.com/job/j1/7')
     bl = BuildsList.from_currnt_build_env()
     bp = BuildPtr.from_currnt_build_env()
     assert len(bl) == 1
     assert id(bl[0]) != id(bp)
     assert bl[0] == bp
示例#7
0
 def test_get_full_url(self, monkeypatch):
     bp = BuildPtr(job_name='j3',
                   job_url='u3',
                   build_id=5,
                   build_url='/u3/5')
     url = bp.get_full_url(jenkins_url='http://jenkins.example.com')
     assert 'http://jenkins.example.com/u3/5' == url
     monkeypatch.setenv('JENKINS_URL', 'http://jenkins.example.org')
     url = bp.get_full_url()
     assert 'http://jenkins.example.org/u3/5' == url
     monkeypatch.delenv('JENKINS_URL', raising=False)
     with pytest.raises(NotInJenkins):
         bp.get_full_url()
示例#8
0
 def test_eq(self, init_prms):
     o1 = BuildPtr(**init_prms)
     o2 = BuildPtr(**init_prms)
     assert id(o1) != id(o2)
     assert o1 == o2
示例#9
0
 def test_as_dict(self, init_prms, exp):
     bp = BuildPtr(**init_prms)
     assert exp == bp.as_dict()
示例#10
0
 def test_as_dict(self, init_prms, exp):
     bp = BuildPtr(**init_prms)
     assert exp == bp.as_dict()