def test_label_validity_check(self): parent_device = self._get_parent_device() free_device = self._get_free_device(parent=parent_device) add_dialog = AddDialog(self.parent_window, parent_device, free_device, [("free", free_device)], self.supported_filesystems, []) add_dialog.devices_combo.set_active_id( "partition") # select device type that has a label option add_dialog.filesystems_combo.set_active_id("ext4") # valid label for ext4 label = "a" * 5 add_dialog.label_entry.set_text(label) add_dialog.validate_user_input() self.assertFalse( self.error_dialog.called) # passphrase specified --> no error self.error_dialog.reset_mock() # invalid label for ext4 label = "a" * 50 add_dialog.label_entry.set_text(label) add_dialog.validate_user_input() self.error_dialog.assert_any_call( add_dialog, _("\"{0}\" is not a valid label.").format(label), True) self.error_dialog.reset_mock()
def test_name_validity_check(self): parent_device = self._get_parent_device() free_device = self._get_free_device(parent=parent_device) add_dialog = AddDialog(self.parent_window, parent_device, free_device, [("free", free_device)], self.supported_filesystems, []) add_dialog.devices_combo.set_active_id( "lvm") # select device type that has a name option # valid name name = "aaaaa" add_dialog.name_entry.set_text(name) add_dialog.validate_user_input() self.assertFalse( self.error_dialog.called) # passphrase specified --> no error self.error_dialog.reset_mock() # invalid name name = "?*#%@" add_dialog.name_entry.set_text(name) add_dialog.validate_user_input() self.error_dialog.assert_any_call( add_dialog, _("\"{0}\" is not a valid name.").format(name), True) self.error_dialog.reset_mock()
def test_name_validity_check(self): parent_device = self._get_parent_device() free_device = self._get_free_device(parent=parent_device) add_dialog = AddDialog(self.parent_window, parent_device, free_device, [("free", free_device)], []) add_dialog.devices_combo.set_active_id("lvm") # select device type that has a name option # valid name name = "aaaaa" add_dialog.name_entry.set_text(name) add_dialog.validate_user_input() self.assertFalse(self.error_dialog.called) # passphrase specified --> no error self.error_dialog.reset_mock() # invalid name name = "?*#%@" add_dialog.name_entry.set_text(name) add_dialog.validate_user_input() self.error_dialog.assert_any_call(add_dialog, _('"{0}" is not a valid name.').format(name), True) self.error_dialog.reset_mock()
def test_mountpoint_validity_check(self): parent_device = self._get_parent_device() free_device = self._get_free_device(parent=parent_device) add_dialog = AddDialog(self.parent_window, parent_device, free_device, [("free", free_device)], self.supported_filesystems, ["/root"], True) # reset mock self.error_dialog.reset_mock() # valid mountpoint add_dialog.mountpoint_entry.set_text("/home") add_dialog.validate_user_input() self.assertFalse(self.error_dialog.called) # passphrase specified --> no error self.error_dialog.reset_mock() # invalid mountpoint mnt = "home" add_dialog.mountpoint_entry.set_text(mnt) add_dialog.validate_user_input() self.error_dialog.assert_any_call(add_dialog, _("\"{0}\" is not a valid mountpoint.").format(mnt), False) self.error_dialog.reset_mock() # duplicate mountpoint mnt = "/root" add_dialog.mountpoint_entry.set_text(mnt) add_dialog.validate_user_input() self.error_dialog.assert_any_call(add_dialog, _("Selected mountpoint \"{0}\" is already set for another device.").format(mnt), False) self.error_dialog.reset_mock()
def test_encrypt_validity_check(self): parent_device = self._get_parent_device() free_device = self._get_free_device(parent=parent_device) add_dialog = AddDialog(self.parent_window, parent_device, free_device, [("free", free_device)], []) # passphrases specified and matches add_dialog.encrypt_check.set_active(True) add_dialog.pass_entry.set_text("aaaaa") add_dialog.pass2_entry.set_text("aaaaa") add_dialog.validate_user_input() self.assertFalse(self.error_dialog.called) # passphrases specified and matches --> no error self.error_dialog.reset_mock() # passphrases specified but don't matche add_dialog.encrypt_check.set_active(True) add_dialog.pass_entry.set_text("aaaaa") add_dialog.pass2_entry.set_text("bbbb") add_dialog.validate_user_input() self.error_dialog.assert_any_call(add_dialog, _("Provided passphrases do not match."), True) self.error_dialog.reset_mock() # no passphrase specified add_dialog.encrypt_check.set_active(True) add_dialog.pass_entry.set_text("") add_dialog.validate_user_input() self.error_dialog.assert_any_call(add_dialog, _("Passphrase not specified."), True) self.error_dialog.reset_mock()
def test_mountpoint_validity_check(self): parent_device = self._get_parent_device() free_device = self._get_free_device(parent=parent_device) add_dialog = AddDialog(self.parent_window, parent_device, free_device, [("free", free_device)], ["/root"], True) # reset mock self.error_dialog.reset_mock() # valid mountpoint add_dialog.mountpoint_entry.set_text("/home") add_dialog.validate_user_input() self.assertFalse(self.error_dialog.called) # passphrase specified --> no error self.error_dialog.reset_mock() # invalid mountpoint mnt = "home" add_dialog.mountpoint_entry.set_text(mnt) add_dialog.validate_user_input() self.error_dialog.assert_any_call(add_dialog, _('"{0}" is not a valid mountpoint.').format(mnt), False) self.error_dialog.reset_mock() # duplicate mountpoint mnt = "/root" add_dialog.mountpoint_entry.set_text(mnt) add_dialog.validate_user_input() self.error_dialog.assert_any_call( add_dialog, _('Selected mountpoint "{0}" is already set for another device.').format(mnt), False ) self.error_dialog.reset_mock()
def test_mountpoint_validity_check(self): parent_device = self._get_parent_device() free_device = self._get_free_device(parent=parent_device) add_dialog = AddDialog(self.parent_window, "disk", parent_device, free_device, [], [free_device], self.supported_raids, self.supported_fs, ["/root"], True) # valid mountpoint add_dialog.mountpoint_entry.set_text("/home") add_dialog.validate_user_input() self.assertFalse(self.error_dialog.called) # passphrase specified --> no error self.error_dialog.reset_mock() # invalid mountpoint mnt = "home" add_dialog.mountpoint_entry.set_text(mnt) add_dialog.validate_user_input() self.error_dialog.assert_any_call(add_dialog, _("\"{0}\" is not a valid mountpoint.").format(mnt)) self.error_dialog.reset_mock() # duplicate mountpoint mnt = "/root" add_dialog.mountpoint_entry.set_text(mnt) add_dialog.validate_user_input() self.error_dialog.assert_any_call(add_dialog, _("Selected mountpoint \"{0}\" is already set for another device.").format(mnt)) self.error_dialog.reset_mock()
def test_label_validity_check(self): parent_device = self._get_parent_device() free_device = self._get_free_device(parent=parent_device) add_dialog = AddDialog(self.parent_window, parent_device, free_device, [("free", free_device)], []) add_dialog.devices_combo.set_active_id("partition") # select device type that has a label option add_dialog.filesystems_combo.set_active_id("ext4") # valid label for ext4 label = "a" * 5 add_dialog.label_entry.set_text(label) add_dialog.validate_user_input() self.assertFalse(self.error_dialog.called) # passphrase specified --> no error self.error_dialog.reset_mock() # invalid label for ext4 label = "a" * 50 add_dialog.label_entry.set_text(label) add_dialog.validate_user_input() self.error_dialog.assert_any_call(add_dialog, _('"{0}" is not a valid label.').format(label), True) self.error_dialog.reset_mock()
def test_label_validity_check(self): parent_device = self._get_parent_device() free_device = self._get_free_device(parent=parent_device) add_dialog = AddDialog(self.parent_window, "disk", parent_device, free_device, [], [free_device], self.supported_raids, self.supported_fs, []) add_dialog.devices_combo.set_active_id("partition") # select device type that has a label option add_dialog.filesystems_combo.set_active_id("ext4") # valid label for ext4 label = "a" * 5 add_dialog.label_entry.set_text(label) add_dialog.validate_user_input() self.assertFalse(self.error_dialog.called) # passphrase specified --> no error self.error_dialog.reset_mock() # invalid label for ext4 label = "a" * 50 add_dialog.label_entry.set_text(label) add_dialog.validate_user_input() self.error_dialog.assert_any_call(add_dialog, "\"%s\" is not a valid label." % label) self.error_dialog.reset_mock()