def test_no_images(self, mock_log): with patch('jujushell._lxd_client') as mock_client: mock_client().images.all.return_value = () jujushell.import_lxd_image('test', self.path) mock_client().images.create.assert_called_once_with(b'AAAAAAAAAA', wait=True) mock_client().images.create().add_alias.assert_called_once_with( 'test', '')
def test_image_exists(self, mock_log): image = Mock() image.fingerprint = \ '1d65bf29403e4fb1767522a107c827b8884d16640cf0e3b18c4c1dd107e0d49d' image.aliases = [{'name': 'test', 'description': ''}] with patch('jujushell._lxd_client') as mock_client: mock_client().images.all.return_value = [image] jujushell.import_lxd_image('test', self.path) mock_client().images.create.assert_not_called()