def test_copy_single_distro_files(create_kernel_initrd, fk_initrd, fk_kernel): # Arrange # Create fake files directory = create_kernel_initrd(fk_kernel, fk_initrd) # Create test API test_api = CobblerAPI() # Get Collection Manager used by the API test_collection_mgr = test_api._collection_mgr # Create a test Distro test_distro = Distro(test_api) test_distro.name = "test_copy_single_distro_files" test_distro.kernel = str(os.path.join(directory, fk_kernel)) test_distro.initrd = str(os.path.join(directory, fk_initrd)) # Add test distro to the API test_api.add_distro(test_distro) # Create class under test test_gen = tftpgen.TFTPGen(test_collection_mgr) # Act test_gen.copy_single_distro_files(test_distro, directory, False) # Assert that path created by function under test is actually there result_kernel = os.path.join(directory, "images", test_distro.name, fk_kernel) result_initrd = os.path.join(directory, "images", test_distro.name, fk_initrd) assert os.path.exists(result_kernel) assert os.path.exists(result_initrd)
def test_to_dict(): # Arrange test_api = CobblerAPI() distro = Distro(test_api) distro.name = "testdistro" test_api.add_distro(distro, save=False) profile = Profile(test_api) profile.name = "testprofile" profile.distro = distro.name # Act result = profile.to_dict() # Assert assert len(result) == 44 assert result["distro"] == "testdistro"