def test_merge(self, yesno, ProgressDialog): self._create_sample_data() dialog = PersonMergeDialog(self.store) dialog.model.same_phone = False dialog.model.same_street = False self.click(dialog.search_button) for row in dialog.dup_tree: if not row.parent: root = row else: # Figure out how to mimic the user clicking the row row.merge = True self.assertEquals(len(root.get_to_merge()), 2) dialog.dup_tree.select(root) with contextlib.nested(mock.patch('stoq.gui.inventory.api.new_store'), mock.patch.object(self.store, 'commit'), mock.patch.object(self.store, 'close')) as ctx: new_store = ctx[0] new_store.return_value = self.store self.click(dialog.merge_button) yesno.assert_called_once_with( 'This will merge 2 persons into 1. Are you sure?', Gtk.ResponseType.NO, 'Merge', "Don't merge") # If we search again, there should be no duplicates self.click(dialog.search_button) self.assertEquals(len(dialog.dup_tree), 0)
def test_search_same_name(self, ProgressDialog): self._create_sample_data() dialog = PersonMergeDialog(self.store) # First, only the exact name dialog.model.same_phone = False dialog.model.same_street = False self.click(dialog.search_button) names = set(d.name for d in dialog.dup_tree) self.assertEqual(names, set([u'José Cuervo Pinga', u'Jose Cuervo Pinga']))
def test_search_first_last_name_address(self, ProgressDialog): self._create_sample_data() dialog = PersonMergeDialog(self.store) dialog.model.method = dialog.model.FIRST_LAST_NAME # First, only the first name and phone dialog.model.same_phone = False dialog.model.same_street = True self.click(dialog.search_button) names = set(d.name for d in dialog.dup_tree) self.assertEquals(names, set([u'José Pinga', 'Jose Cuervo Pinga']))
def test_search(self, ProgressDialog): dialog = PersonMergeDialog(self.store) self.click(dialog.search_button) ProgressDialog.assert_called_once_with('Searching duplicates', pulse=False)
def test_create(self): dialog = PersonMergeDialog(self.store) self.check_editor(dialog, 'dialog-person-merge-dialog')