Beispiel #1
0
 def test_from_env_json(self, monkeypatch):
     exp = BuildsList.from_dict_list(self.data)
     monkeypatch.setenv('BUILDS_LIST', self.data_str)
     bl = BuildsList.from_env_json()
     assert id(exp) != id(bl)
     assert exp == bl
     monkeypatch.delenv('BUILDS_LIST', raising=False)
     bl = BuildsList.from_env_json()
     assert bl == []
Beispiel #2
0
 def test_from_env_json(self, monkeypatch):
     exp = BuildsList.from_dict_list(self.data)
     monkeypatch.setenv('BUILDS_LIST', self.data_str)
     bl = BuildsList.from_env_json()
     assert id(exp) != id(bl)
     assert exp == bl
     monkeypatch.delenv('BUILDS_LIST', raising=False)
     bl = BuildsList.from_env_json()
     assert bl == []
Beispiel #3
0
 def test_add(self):
     bl1 = BuildsList.from_dict_list(self.data)
     bl2 = BuildsList.from_dict_list(self.more_data)
     exp_data = self.data + self.more_data
     exp_bl = BuildsList.from_dict_list(exp_data)
     out_bl = bl1 + bl2
     assert id(out_bl) != id(exp_bl)
     assert out_bl == exp_bl
     assert len(out_bl) == len(self.data) + len(self.more_data)
     assert isinstance(out_bl, BuildsList)
Beispiel #4
0
 def test_add(self):
     bl1 = BuildsList.from_dict_list(self.data)
     bl2 = BuildsList.from_dict_list(self.more_data)
     exp_data = self.data + self.more_data
     exp_bl = BuildsList.from_dict_list(exp_data)
     out_bl = bl1 + bl2
     assert id(out_bl) != id(exp_bl)
     assert out_bl == exp_bl
     assert len(out_bl) == len(self.data) + len(self.more_data)
     assert isinstance(out_bl, BuildsList)
Beispiel #5
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)
Beispiel #6
0
 def test_as_repoman_conf(self, monkeypatch):
     monkeypatch.setenv('JENKINS_URL', 'http://jenkins.example.org')
     exp = dedent("""
         http://jenkins.example.org/u3/5
         http://jenkins.example.org/u4/3
     """).lstrip()
     bl = BuildsList.from_dict_list(self.more_data)
     out = bl.as_repoman_conf()
     assert exp == out
Beispiel #7
0
    def visible_builds(self):
        """Get all builds from visible changes

        rtype: BuildsList
        returns: the set of builds tracked by visible_changes
        """
        return BuildsList(chain.from_iterable(
            ChangeWithBuildsWrapper(c).builds for c in self.visible_changes
        ))
Beispiel #8
0
 def test_as_repoman_conf(self, monkeypatch):
     monkeypatch.setenv('JENKINS_URL', 'http://jenkins.example.org')
     exp = dedent("""
         http://jenkins.example.org/u3/5
         http://jenkins.example.org/u4/3
     """).lstrip()
     bl = BuildsList.from_dict_list(self.more_data)
     out = bl.as_repoman_conf()
     assert exp == out
Beispiel #9
0
class ChangeWithBuilds(object_witp_opt_attrs):
    """Base/Mixin class for change objects that track build jobs to get built
    artifacts

    Builds are specified as a BuildsList object
    """
    default_builds = BuildsList()

    def set_builds_from_env(self, env_var='BUILDS_LIST'):
        self.builds = BuildsList.from_env_json(env_var)
 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
Beispiel #11
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
Beispiel #12
0
 def test_as_dict_list(self):
     bl = BuildsList.from_dict_list(self.data)
     out = bl.as_dict_list()
     assert self.data == out
Beispiel #13
0
 def test_from_dict_list(self):
     bl = BuildsList.from_dict_list(self.data)
     assert len(self.data) == len(bl)
     assert next((False for b in bl if not isinstance(b, BuildPtr)), True)
Beispiel #14
0
 def test_from_json_str(self):
     exp = BuildsList.from_dict_list(self.data)
     bl = BuildsList.from_json_str(self.data_str)
     assert id(exp) != id(bl)
     assert exp == bl
Beispiel #15
0
 def test_from_dict_list(self):
     bl = BuildsList.from_dict_list(self.data)
     assert len(self.data) == len(bl)
     assert next((False for b in bl if not isinstance(b, BuildPtr)), True)
Beispiel #16
0
 def test_from_json_str(self):
     exp = BuildsList.from_dict_list(self.data)
     bl = BuildsList.from_json_str(self.data_str)
     assert id(exp) != id(bl)
     assert exp == bl
Beispiel #17
0
 def set_current_build_from_env(self):
     self.builds = BuildsList.from_currnt_build_env()
Beispiel #18
0
 def set_builds_from_env(self, env_var='BUILDS_LIST'):
     self.builds = BuildsList.from_env_json(env_var)
Beispiel #19
0
 def set_current_build_from_env(self):
     self.builds = BuildsList.from_currnt_build_env()
Beispiel #20
0
 def test_as_dict_list(self):
     bl = BuildsList.from_dict_list(self.data)
     out = bl.as_dict_list()
     assert self.data == out
Beispiel #21
0
 def set_builds_from_env(self, env_var='BUILDS_LIST'):
     self.builds = BuildsList.from_env_json(env_var)