535
535
class TestImportPxeFiles(PservTestCase):
537
def test_import_pxe_files(self):
538
recorder = self.patch(tasks, 'check_call', Mock())
540
recorder.assert_called_once_with(['maas-import-pxe-files'], env=ANY)
541
self.assertIsInstance(import_pxe_files, Task)
543
def test_import_pxe_files_preserves_environment(self):
544
recorder = self.patch(tasks, 'check_call', Mock())
546
recorder.assert_called_once_with(
547
['maas-import-pxe-files'], env=os.environ)
549
def test_import_pxe_files_sets_proxy(self):
537
def make_archive_url(self, name=None):
539
name = factory.make_name('archive')
540
return 'http://%s.example.com/%s' % (name, factory.make_name('path'))
542
def test_import_boot_images(self):
543
recorder = self.patch(tasks, 'check_call', Mock())
545
recorder.assert_called_once_with(
546
['sudo', '-n', '-E', 'maas-import-pxe-files'], env=ANY)
547
self.assertIsInstance(import_boot_images, Task)
549
def test_import_boot_images_preserves_environment(self):
550
recorder = self.patch(tasks, 'check_call', Mock())
552
recorder.assert_called_once_with(
553
['sudo', '-n', '-E', 'maas-import-pxe-files'], env=os.environ)
555
def test_import_boot_images_sets_proxy(self):
550
556
recorder = self.patch(tasks, 'check_call', Mock())
551
557
proxy = factory.getRandomString()
552
import_pxe_files(http_proxy=proxy)
558
import_boot_images(http_proxy=proxy)
553
559
expected_env = dict(os.environ, http_proxy=proxy, https_proxy=proxy)
554
560
recorder.assert_called_once_with(
555
['maas-import-pxe-files'], env=expected_env)
561
['sudo', '-n', '-E', 'maas-import-pxe-files'], env=expected_env)
563
def test_import_boot_images_sets_archive_locations(self):
564
self.patch(tasks, 'check_call')
566
'main_archive': self.make_archive_url('main'),
567
'ports_archive': self.make_archive_url('ports'),
568
'cloud_images_archive': self.make_archive_url('cloud-images'),
570
expected_settings = {
571
parameter.upper(): value
572
for parameter, value in archives.items()}
573
import_boot_images(**archives)
574
env = tasks.check_call.call_args[1]['env']
577
for variable, value in env.iteritems()
578
if variable.endswith('_ARCHIVE')}
579
self.assertEqual(expected_settings, archive_settings)