Example #1
0
File: tests.py Project: herlo/tunir
 def test_metadata_userdata(self, s_call):
     """
     Tests metadata and userdata creation
     """
     path = '/tmp/test_tunir'
     seed_path = '/tmp/test_tunir/seed.img'
     meta_path = '/tmp/test_tunir/meta/'
     metadata_filepath = '/tmp/test_tunir/meta/meta-data'
     userdata_filepath = '/tmp/test_tunir/meta/user-data'
     testvm.clean_dirs(path)
     testvm.create_dirs(os.path.join(path, 'meta'))
     create_initrd_kernel()
     base_path = path
     testvm.create_user_data(base_path, "passw0rd")
     testvm.create_meta_data(base_path, "test_tunir")
     self.assertTrue(os.path.exists(metadata_filepath))
     self.assertTrue(os.path.exists(userdata_filepath))
     testvm.create_seed_img(meta_path, path)
     self.assertTrue(os.path.exists(seed_path))
     s_call.assert_called_once_with(['virt-make-fs',
                               '--type=msdos',
                               '--label=cidata',
                               meta_path,
                               path + '/seed.img'])
     testvm.clean_dirs(path)
Example #2
0
File: tests.py Project: herlo/tunir
 def test_download_initrd_kernel_exception(self, s_call):
     """
     Tests the initrd and kernel extraction.
     """
     testvm.clean_dirs('/tmp/test_tunir')
     create_initrd_kernel(missing=True)
     with captured_output() as (out, err):
         result= testvm.download_initrd_and_kernel('/tmp/test_tunir/test.qcow2', '/tmp/test_tunir')
     self.assertIn("Unable to find kernel or initrd, did they download?", out.getvalue())
Example #3
0
File: tests.py Project: herlo/tunir
 def test_directory_handling(self):
     """
     Tests metadata dir creation details.
     """
     path = '/tmp/test_tunir'
     testvm.clean_dirs(path)
     self.assertFalse(os.path.exists(path))
     testvm.create_dirs(path)
     self.assertTrue(os.path.exists(path))
     testvm.clean_dirs()
Example #4
0
File: tests.py Project: herlo/tunir
    def test_boot_image(self, s_popen):
        res = StupidProcess()
        s_popen.return_value = res

        path = '/tmp/test_tunir'
        seed_path = '/tmp/test_tunir/seed.img'
        testvm.clean_dirs(path)
        testvm.create_dirs(os.path.join(path, 'meta'))
        with captured_output() as (out, err):
            testvm.boot_image('/tmp/test_tunir/test.qcow2', seed_path)
        self.assertIn("PID: 42", out.getvalue())