def test_re_config_file_with_default_arch(self): arch = factory.make_name("arch", sep="").encode("ascii") match = re_config_file.match(b"grub/grub.cfg-default-%s" % arch) self.assertIsNotNone(match) self.assertEqual( {"mac": None, "arch": arch, "subarch": None}, match.groupdict() )
def test_re_config_file_matches_grub_cfg_with_leading_slash(self): mac = b"aa:bb:cc:dd:ee:ff" match = re_config_file.match(b"/grub/grub.cfg-%s" % mac) self.assertIsNotNone(match) self.assertEqual( {"mac": mac, "arch": None, "subarch": None}, match.groupdict() )
def test_re_config_file_with_default_arch(self): arch = factory.make_name('arch', sep='').encode("ascii") match = re_config_file.match(b'grub/grub.cfg-default-%s' % arch) self.assertIsNotNone(match) self.assertEqual( {'mac': None, 'arch': arch, 'subarch': None}, match.groupdict())
def test_re_config_file_matches_grub_cfg_with_leading_slash(self): mac = b'aa:bb:cc:dd:ee:ff' match = re_config_file.match(b'/grub/grub.cfg-%s' % mac) self.assertIsNotNone(match) self.assertEqual( {'mac': mac, 'arch': None, 'subarch': None}, match.groupdict())
def test_re_config_file_with_default(self): match = re_config_file.match(b'grub/grub.cfg-default') self.assertIsNotNone(match) self.assertEqual({ 'mac': None, 'arch': None, 'subarch': None }, match.groupdict())
def test_re_config_file_is_compatible_with_cfg_path_generator(self): # The regular expression for extracting components of the file path is # compatible with the PXE config path generator. for iteration in range(10): config_path, args = self.get_example_path_and_components() match = re_config_file.match(config_path) self.assertIsNotNone(match, config_path) self.assertEqual(args, match.groupdict())
def test_re_config_file_with_default(self): match = re_config_file.match(b"grub/grub.cfg-default") self.assertIsNotNone(match) self.assertEqual({ "mac": None, "arch": None, "subarch": None }, match.groupdict())
def test_re_config_file_matches_classic_grub_cfg(self): # The default config path is simply "grub.cfg-{mac}" (without # leading slash). The regex matches this. mac = b"aa:bb:cc:dd:ee:ff" match = re_config_file.match(b"grub/grub.cfg-%s" % mac) self.assertIsNotNone(match) self.assertEqual( {"mac": mac, "arch": None, "subarch": None}, match.groupdict() )
def test_re_config_file_without_leading_slash(self): # The regular expression for extracting components of the file path # doesn't care if there's no leading forward slash; the TFTP server is # easy on this point, so it makes sense to be also. config_path, args = self.get_example_path_and_components() # Ensure there's no leading slash. config_path = config_path.lstrip(b"/") match = re_config_file.match(config_path) self.assertIsNotNone(match, config_path) self.assertEqual(args, match.groupdict())
def test_re_config_file_does_not_match_default_grub_config_file(self): self.assertIsNone(re_config_file.match(b'grub/grub.cfg'))