Example #1
0
def test_check_upstream_release(status_code, latest_release):
    """test func."""
    resp = mock.Mock()
    resp.status = status_code
    m_manager = mock.Mock()
    m_manager.request.return_value = resp
    with mock.patch('buku.urllib3') as m_urllib3, \
            mock.patch('buku.print') as m_print:
        import buku
        if latest_release:
            latest_version = 'v{}'.format(buku.__version__)
        else:
            latest_version = 'v0'
        m_urllib3.PoolManager.return_value = m_manager
        resp.data.decode.return_value = json.dumps([{'tag_name': latest_version}])
        buku.check_upstream_release()
        if status_code != 200:
            return
        len(m_print.mock_calls) == 1
Example #2
0
def test_check_upstream_release(status_code, latest_release):
    """test func."""
    resp = mock.Mock()
    resp.status = status_code
    m_manager = mock.Mock()
    m_manager.request.return_value = resp
    with mock.patch('buku.urllib3') as m_urllib3, \
            mock.patch('buku.print') as m_print:
        import buku
        if latest_release:
            latest_version = 'v{}'.format(buku.__version__)
        else:
            latest_version = 'v0'
        m_urllib3.PoolManager.return_value = m_manager
        resp.data.decode.return_value = json.dumps([{'tag_name': latest_version}])
        buku.check_upstream_release()
        if status_code != 200:
            return
        len(m_print.mock_calls) == 1
Example #3
0
def test_check_upstream_release(status_code, latest_release):
    """test func."""
    resp = mock.Mock()
    resp.status_code = status_code
    with mock.patch('buku.requests') as m_requests, \
            mock.patch('buku.print') as m_print:
        import buku
        if latest_release:
            latest_version = 'v{}'.format(buku.__version__)
        else:
            latest_version = 'v0'
        resp.json.return_value = [{'tag_name': latest_version}]
        m_requests.get.return_value = resp
        buku.check_upstream_release()
        if status_code != 200:
            return
        if latest_release:
            print_text = 'This is the latest release'
        else:
            print_text = 'Latest upstream release is %s' % latest_version
        m_print.assert_called_once_with(print_text)
Example #4
0
def test_check_upstream_release(status_code, latest_release):
    """test func."""
    resp = mock.Mock()
    resp.status_code = status_code
    with mock.patch('buku.requests') as m_requests, \
            mock.patch('buku.print') as m_print:
        import buku
        if latest_release:
            latest_version = 'v{}'.format(buku.__version__)
        else:
            latest_version = 'v0'
        resp.json.return_value = [{'tag_name': latest_version}]
        m_requests.get.return_value = resp
        buku.check_upstream_release()
        if status_code != 200:
            return
        if latest_release:
            print_text = 'This is the latest release'
        else:
            print_text = 'Latest upstream release is %s' % latest_version
        m_print.assert_called_once_with(print_text)