Пример #1
0
    def test_legacy_get_clobber_times(self, mock_urlopen):
        lastclobber_fmt = '{}:{}:{}\n'
        builddir = 'the-roadhouse'
        timestamp = 9999
        who = '*****@*****.**'

        fake_data_str = lastclobber_fmt.format(builddir, timestamp, who)
        urllib2_mock = mock.Mock()
        urllib2_mock.read.side_effect = [fake_data_str]
        mock_urlopen.return_value = urllib2_mock

        clobber_dates_return = legacy_get_clobber_times(
            'clobberer/lastclobber',
            'branch',
            'buildername',
            'builddir',
            'slave',
            'master',
        )

        self.assertDictEqual(
            clobber_dates_return,
            {
                'result': [{
                    'builddir': builddir,
                    'lastclobber': timestamp,
                    'who': who,
                    'slave': None
                }]
            }
        )
Пример #2
0
    def test_legacy_get_clobber_times_null(self, mock_urlopen):
        # make sure it can handle no data
        fake_data_str = ""
        urllib2_mock = mock.Mock()
        urllib2_mock.read.side_effect = [fake_data_str]
        mock_urlopen.return_value = urllib2_mock

        clobber_dates_return = legacy_get_clobber_times(
            'clobberer/lastclobber',
            'branch',
            'buildername',
            'builddir',
            'slave',
            'master',
        )
        self.assertDictEqual(clobber_dates_return, {'result': []})