Esempio n. 1
0
 def test_update_available(self, mock_lgr):
     class MockException(Exception):
         pass
     mock_lgr.return_value = {'name': 'v1.4.0', 'html_url': 'link'}
     self.assertIsNone(utils.update_available())
     mock_lgr.return_value['name'] = 'v1.5.0'
     self.assertIsNone(utils.update_available())
     mock_lgr.return_value['name'] = 'v1.5.1'
     self.assertEqual(utils.update_available(), 'link')
     mock_lgr.return_value['name'] = 'v1.6.1'
     self.assertEqual(utils.update_available(), 'link')
     mock_lgr.return_value['name'] = 'v2.0.0'
     self.assertEqual(utils.update_available(), 'link')
     mock_lgr.return_value = {'error': 'unavailable'}
     self.assertIsNone(utils.update_available())
     mock_lgr.return_value = None
     self.assertIsNone(utils.update_available())
     mock_lgr.side_effect = MockException
     self.assertIsNone(utils.update_available())
     with self.assertRaises(MockException):
         utils.update_available(silent_fail=False)
Esempio n. 2
0
 def test_update_available(self, mock_lgr):
     class MockException(Exception):
         pass
     mock_lgr.return_value = {'name': 'v1.4.0', 'html_url': 'link'}
     self.assertIsNone(utils.update_available())
     mock_lgr.return_value['name'] = 'v1.5.0'
     self.assertIsNone(utils.update_available())
     mock_lgr.return_value['name'] = 'v1.5.1'
     self.assertEqual(utils.update_available(), 'link')
     mock_lgr.return_value['name'] = 'v1.6.1'
     self.assertEqual(utils.update_available(), 'link')
     mock_lgr.return_value['name'] = 'v2.0.0'
     self.assertEqual(utils.update_available(), 'link')
     mock_lgr.return_value = {'error': 'unavailable'}
     self.assertIsNone(utils.update_available())
     mock_lgr.return_value = None
     self.assertIsNone(utils.update_available())
     mock_lgr.side_effect = MockException
     self.assertIsNone(utils.update_available())
     with self.assertRaises(MockException):
         utils.update_available(silent_fail=False)
Esempio n. 3
0
def cli():
    update_url = update_available()
    if update_url:
        click.echo("INFO: A newer version of shub is available. Update "
                   "via pip or get it at {}".format(update_url),
                   err=True)
Esempio n. 4
0
def cli():
    update_url = update_available()
    if update_url:
        click.echo("INFO: A newer version of shub is available. Update "
                   "via pip or get it at {}".format(update_url),  err=True)