def test_Registry_init (): key = registry.Registry (TEST_KEY, access=win32con.KEY_ALL_ACCESS) assert key.moniker == TEST_KEY assert key.name == "winsys" assert key.access == win32con.KEY_ALL_ACCESS print key.id assert key.id == registry._parse_moniker (TEST_KEY.lower ())
def test_Registry_from_string(self): key = registry.Registry.from_string(TEST_KEY) self.assertEqual(key.moniker, TEST_KEY) self.assertEqual( key.access, registry.Registry._access(registry.Registry.DEFAULT_ACCESS)) self.assertEqual(key.id, registry._parse_moniker(TEST_KEY.lower()))
def test_moniker_computer_root_and_body (self): self.assertEquals (registry._parse_moniker (r"\\COMPUTER\HKLM\Software\Microsoft"), ("COMPUTER", win32con.HKEY_LOCAL_MACHINE, r"Software\Microsoft", None))
def test_moniker_root_only (self): self.assertEquals (registry._parse_moniker ("HKLM"), (None, win32con.HKEY_LOCAL_MACHINE, "", None))
def test_moniker_invalid_root (self): with self.assertRaises (registry.x_moniker_no_root): registry._parse_moniker (r"<nonsense>")
def test_moniker_root_and_body(self): self.assertEqual( registry._parse_moniker(r"HKLM\Software\Microsoft"), (None, win32con.HKEY_LOCAL_MACHINE, r"Software\Microsoft", None))
def test_Registry_init(self): key = registry.Registry(TEST_KEY, access=win32con.KEY_ALL_ACCESS) self.assertEqual(key.moniker, TEST_KEY) self.assertEqual(key.name, "winsys") self.assertEqual(key.access, win32con.KEY_ALL_ACCESS) self.assertEqual(key.id, registry._parse_moniker(TEST_KEY.lower()))
def test_moniker_invalid_root (): registry._parse_moniker (r"<nonsense>")
def test_Registry_from_string (self): key = registry.Registry.from_string (TEST_KEY) assert key.moniker == TEST_KEY assert key.access == registry.Registry._access (registry.Registry.DEFAULT_ACCESS) assert key.id == registry._parse_moniker (TEST_KEY.lower ())
def test_moniker_default_value (): assert_equals (registry._parse_moniker (r"HKLM\Software\Microsoft:"), (None, win32con.HKEY_LOCAL_MACHINE, r"Software\Microsoft", ""))
def test_moniker_create (): parts = "COMPUTER", win32con.HKEY_LOCAL_MACHINE, "PATH", "VALUE" assert_equals (registry._parse_moniker (registry.create_moniker (*parts)), parts)
def test_moniker_body_only (): registry._parse_moniker (r"Software\Microsoft")
def test_moniker_root_only (): assert_equals (registry._parse_moniker ("HKLM"), (None, win32con.HKEY_LOCAL_MACHINE, "", None))
def test_moniker_slash_and_root (): assert_equals (registry._parse_moniker (r"\HKLM"), (None, win32con.HKEY_LOCAL_MACHINE, "", None))
def test_moniker_value (self): self.assertEquals (registry._parse_moniker (r"HKLM\Software\Microsoft:value"), (None, win32con.HKEY_LOCAL_MACHINE, r"Software\Microsoft", "value"))
def test_moniker_computer_only(self): with self.assertRaises(registry.x_moniker_no_root): registry._parse_moniker(r"\\computer")
def test_moniker_create (self): parts = "COMPUTER", win32con.HKEY_LOCAL_MACHINE, "PATH", None self.assertEquals (registry._parse_moniker (registry.create_moniker (*parts)), parts)
def test_moniker_invalid_root(self): with self.assertRaises(registry.x_moniker_no_root): registry._parse_moniker(r"<nonsense>")
def test_moniker_create(self): parts = "COMPUTER", win32con.HKEY_LOCAL_MACHINE, "PATH", None self.assertEqual(registry._parse_moniker(registry.create_moniker(*parts)), parts)
def test_moniker_slash_and_root(self): self.assertEqual(registry._parse_moniker(r"\HKLM"),(None, win32con.HKEY_LOCAL_MACHINE, "", None))
def test_Registry_from_string(self): key = registry.Registry.from_string(TEST_KEY) self.assertEqual(key.moniker, TEST_KEY) self.assertEqual(key.access, registry.Registry._access(registry.Registry.DEFAULT_ACCESS)) self.assertEqual(key.id, registry._parse_moniker(TEST_KEY.lower()))
def test_moniker_root_only(self): self.assertEqual(registry._parse_moniker("HKLM"),(None, win32con.HKEY_LOCAL_MACHINE, "", None))
def test_moniker_computer_and_root(self): self.assertEqual(registry._parse_moniker(r"\\COMPUTER\HKLM"),("COMPUTER", win32con.HKEY_LOCAL_MACHINE, "", None))
def test_moniker_computer_only (self): with self.assertRaises (registry.x_moniker_no_root): registry._parse_moniker (r"\\computer")
def test_moniker_root_and_body(self): self.assertEqual(registry._parse_moniker(r"HKLM\Software\Microsoft"),(None, win32con.HKEY_LOCAL_MACHINE, r"Software\Microsoft", None))
def test_moniker_slash_and_root (self): self.assertEquals (registry._parse_moniker (r"\HKLM"), (None, win32con.HKEY_LOCAL_MACHINE, "", None))
def test_moniker_computer_root_and_body(self): self.assertEqual(registry._parse_moniker(r"\\COMPUTER\HKLM\Software\Microsoft"),("COMPUTER", win32con.HKEY_LOCAL_MACHINE, r"Software\Microsoft", None))
def test_moniker_computer_and_root (self): self.assertEquals (registry._parse_moniker (r"\\COMPUTER\HKLM"), ("COMPUTER", win32con.HKEY_LOCAL_MACHINE, "", None))
def test_moniker_body_only(self): with self.assertRaises(registry.x_moniker_no_root): registry._parse_moniker(r"Software\Microsoft")
def test_moniker_body_only (self): with self.assertRaises (registry.x_moniker_no_root): registry._parse_moniker (r"Software\Microsoft")
def test_moniker_value(self): self.assertEqual(registry._parse_moniker(r"HKLM\Software\Microsoft:value"),(None, win32con.HKEY_LOCAL_MACHINE, r"Software\Microsoft", "value"))
def test_moniker_create_named_root (self): parts = "COMPUTER", "HKLM", "PATH", "VALUE" result = "COMPUTER", win32con.HKEY_LOCAL_MACHINE, "PATH", "VALUE" self.assertEquals (registry._parse_moniker (registry.create_moniker (*parts)), result)
def test_moniker_create_named_root(self): parts = "COMPUTER", "HKLM", "PATH", "VALUE" result = "COMPUTER", win32con.HKEY_LOCAL_MACHINE, "PATH", "VALUE" self.assertEqual(registry._parse_moniker(registry.create_moniker(*parts)), result)
def test_moniker_computer_only (): registry._parse_moniker (r"\\computer")