Пример #1
0
 def setUpClass(cls):
     # print("doing setup with", cls.param)
     set_det_id(True)  # handles must be deterministic for this test
     cls.dbstate = DbState()
     cls.dbman = CLIDbManager(cls.dbstate)
     dirpath, _name = cls.dbman.create_new_db_cli("Test: %s" % cls.param,
                                                  dbid=cls.param)
     cls.db = make_database(cls.param)
     cls.db.load(dirpath, None)
Пример #2
0
 def setUpClass(cls):
     # print("doing setup with", cls.param)
     set_det_id(True)  # handles must be deterministic for this test
     cls.dbstate = DbState()
     cls.dbman = CLIDbManager(cls.dbstate)
     dirpath, _name = cls.dbman.create_new_db_cli("Test: %s" % cls.param,
                                                  dbid=cls.param)
     cls.db = make_database(cls.param)
     cls.db.load(dirpath, None)
Пример #3
0
    def __init__(self, dbstate, user, options_class, name, callback=None):
        set_det_id(True)
        uistate = user.uistate
        if not uistate: return

        tool.Tool.__init__(self, dbstate, options_class, name)

        self.window_name = _('Deterministic ID Tool')
        ManagedWindow.__init__(self, uistate, [], self.__class__)

        window = MyWindow(dbstate, self.uistate, [])
        self.set_window(window, None, self.window_name)
        WarningDialog(self.window_name,
              _("The ID and handles now start at 0x00000000, and increment by 0x100000001"),
                self.window)
        self.close()
Пример #4
0
 def test_tcg_and_check_and_repair(self):
     """
     Run a 'Test Case Generator' and 'Check & Repair Database' test.
     Note that the 'Test Case Generator" uses a lot of random numbers to
     generate its test cases.  This makes it less than ideal for a
     predictable unit test.  Still it contains good code for testing the
     'Check and Repair' tool.  So I force the random functions to be
     predictable by seeding it with a fixed number.  I also used the
     'Deterministic ID' function to make the usual db handle generation
     stop using random numbers and potentially reduce Gramps version to
     version issues.
     """
     # the TCG creates bad strings with illegal characters, so we need to
     # ignore them when we print the results
     try:
         sys.stderr = codecs.getwriter(sys.getdefaultencoding()) \
             (sys.stderr.buffer, 'replace')
         sys.stdout = codecs.getwriter(sys.getdefaultencoding()) \
             (sys.stdout.buffer, 'replace')
     except:
         pass
     tst_file = os.path.join(TEST_DIR, "data.gramps")
     set_det_id(True)
     # the following line assumes that TCG has run through init code, where
     # it puts 'myrand', a 'Random' class object, into the 'const' module so
     # we can access it here.
     const.myrand.seed(1234, version=1)
     # print(const.myrand.random())
     #         out, err = call("-s")
     #         expect = ["bsddb"]
     #         check_res(out, err, expect, do_out=True)
     out, err = call("-C", TREE_NAME, "-q", "--import", tst_file)
     expect = [
         "Opened successfully!", "data.gramps, format gramps.",
         "Cleaning up."
     ]
     self.assertTrue(check_res(out, err, expect, do_out=False))
     self.assertEqual(out, "")
     out, err = call(
         "-O", TREE_NAME, "-y", "-q", "-a", "tool", "-p",
         "name=testcasegenerator,bugs=1,persons=0,"
         "add_linebreak=0,add_serial=0,"
         "long_names=0,lowlevel=0,person_count=20,"
         "specialchars=0")
     expect = [
         "Opened successfully!", "Performing action: tool.",
         "Using options string: name=testcasegenerator,bugs=1",
         "Cleaning up."
     ]
     self.assertTrue(check_res(out, err, expect, do_out=False))
     expect = ["person count 41"]
     self.assertTrue(check_res(out, err, expect, do_out=True))
     out, err = call("-O", TREE_NAME, "-y", "-a", "tool", "-p",
                     "name=check")
     expect = [
         "7 broken child/family links were fixed",
         "4 broken spouse/family links were fixed",
         "1 place alternate names fixed",
         "10 media objects were referenced, but not found",
         "References to 10 media objects were kept",
         "3 events were referenced, but not found",
         "1 invalid birth event name was fixed",
         "1 invalid death event name was fixed",
         "2 places were referenced, but not found",
         "13 citations were referenced, but not found",
         "16 sources were referenced, but not found",
         "7 empty objects removed", "1 person objects", "1 family objects",
         "1 event objects", "1 source objects", "0 media objects",
         "0 place objects", "1 repository objects", "1 note objects"
     ]
     self.assertTrue(check_res(out, err, expect, do_out=True))
     expect = [
         "Opened successfully!", "Performing action: tool.",
         "Using options string: name=check", "Cleaning up."
     ]
     self.assertTrue(check_res(out, err, expect, do_out=False))
Пример #5
0
    def test_tcg_and_check_and_repair(self):
        """
        Run a 'Test Case Generator' and 'Check & Repair Database' test.
        Note that the 'Test Case Generator" uses a lot of random numbers to
        generate its test cases.  This makes it less than ideal for a
        predictable unit test.  Still it contains good code for testing the
        'Check and Repair' tool.  So I force the random functions to be
        predictable by seeding it with a fixed number.  I also used the
        'Deterministic ID' function to make the usual db handle generation
        stop using random numbers and potentially reduce Gramps version to
        version issues.
        """
        # the TCG creates bad strings with illegal characters, so we need to
        # ignore them when we print the results
        try:
            sys.stderr = codecs.getwriter(sys.getdefaultencoding()) \
                (sys.stderr.buffer, 'replace')
            sys.stdout = codecs.getwriter(sys.getdefaultencoding()) \
                (sys.stdout.buffer, 'replace')
        except:
            pass
        tst_file = os.path.join(TEST_DIR, "data.gramps")
        set_det_id(True)
        # the following line assumes that TCG has run through init code, where
        # it puts 'myrand', a 'Random' class object, into the 'const' module so
        # we can access it here.
        const.myrand.seed(1234, version=1)
        # print(const.myrand.random())
#         out, err = call("-s")
#         expect = ["bsddb"]
#         check_res(out, err, expect, do_out=True)
        out, err = call("-C", TREE_NAME, "-q",
                        "--import", tst_file)
        expect = ["Opened successfully!",
                  "data.gramps, format gramps.",
                  "Cleaning up."]
        self.assertTrue(check_res(out, err, expect, do_out=False))
        self.assertEqual(out, "")
        out, err = call("-O", TREE_NAME,
                        "-y", "-q", "-a", "tool", "-p",
                        "name=testcasegenerator,bugs=1,persons=1,"
                        "add_linebreak=1,add_serial=1,"
                        "long_names=1,lowlevel=0,person_count=50,"
                        "specialchars=1")
        expect = ["Opened successfully!",
                  "Performing action: tool.",
                  "Using options string: name=testcasegenerator,bugs=1",
                  "Cleaning up."]
        self.assertTrue(check_res(out, err, expect, do_out=False))
        expect = ["person count 41"]
        self.assertTrue(check_res(out, err, expect, do_out=True))
        out, err = call("-O", TREE_NAME,
                        "-y", "-a", "tool", "-p", "name=check")
        expect = ["7 broken child/family links were fixed",
                  "4 broken spouse/family links were fixed",
                  "1 place alternate name fixed",
                  "10 media objects were referenced, but not found",
                  "References to 10 media objects were kept",
                  "3 events were referenced, but not found",
                  "1 invalid birth event name was fixed",
                  "1 invalid death event name was fixed",
                  "2 places were referenced, but not found",
                  "14 citations were referenced, but not found",
                  "17 sources were referenced, but not found",
                  "9 Duplicated Gramps IDs fixed",
                  "7 empty objects removed",
                  "1 person objects",
                  "1 family objects",
                  "1 event objects",
                  "1 source objects",
                  "0 media objects",
                  "0 place objects",
                  "1 repository objects",
                  "1 note objects"]
        self.assertTrue(check_res(out, err, expect, do_out=True))
        expect = ["Opened successfully!",
                  "Performing action: tool.",
                  "Using options string: name=check",
                  "Cleaning up."]
        self.assertTrue(check_res(out, err, expect, do_out=False))