def test_basic_db_function_Geni(self):
        '''
        Testing basic database functionality
        '''
        db_geni = geni_database_interface()
        prof = db_geni.get_profile_by_ID("1149810")
        assert ("profile-403" in db_geni.profiles)
        assert (db_geni.get_profile_by_ID("profile-405"))
        assert (prof.get_specific_event("baptism").get_accuracy() == "BETWEEN")
        assert (prof.get_specific_event("baptism").year_end == 1901)

        fam = db_geni.get_family_by_ID("union-155")
        assert (len(fam.union_data["partners"]) == 2)
        assert (not "union-1349" in db_geni.families)
        #Testing getting the child
        assert (db_geni.get_family_from_child("profile-403"))
        assert ("union-1349" in db_geni.families)
        #Testing getting the children
        children = db_geni.get_all_children("profile-403")
        assert (len(children) == 4)
        assert ("profile-405" in children)
        #Checking the families where is parent the profile
        families = db_geni.get_all_family_ids_is_parent("profile-403")
        assert ("union-155" in families)

        assert ('profile-404'
                in db_geni.get_partners_from_profile("profile-403"))
Exemplo n.º 2
0
 def testCousinsExecution(self):
     '''
     We will test the cousins execution in different way. Will be tested by
     number, not by person
     '''
     #Database creation
     geni_db = geni_database_interface()
     philip = profile(COUSIN_PROFILE)
     generations = 2
     
     climber = climb(geni_db)
     ancestors, anc_count, profiles = climber.get_cousins(philip, generations)
     
     total_center = 0
     total_outside = 0
     for i in range(0, generations+1):
         total_center = total_center + anc_count[i][i]
         for j in range(i+1, generations + 1):
             total_outside = total_outside + anc_count[i][j]
     assert(total_center == 7) 
     assert(total_outside == 0) 
     
     total_final = 0
     for i in range(0, generations+1):
         for j in range(0, generations + 1):
             total_final = total_final + anc_count[i][j]
     assert(total_final == 36)
     assert(len(profiles) == 36)
    def test_simple_process(self):
        '''
        Testing basic execution of the checker
        '''
        input_file = os.path.join(self.filelocation, "Rootstest.rmgc")
        working_file = os.path.join(self.filelocation,
                                    "Rootstest_process.rmgc")

        if os.path.exists(working_file): os.remove(working_file)
        copyfile(input_file, working_file)

        db = database_rm(working_file)
        db_geni = geni_database_interface()
        processor = process_a_db(db, db_geni, event_year_task=1)
        processor.process()

        aunt_prof = db_geni.get_profile_by_ID(
            "https://sandbox.geni.com/people/Aunt-Profile/1231306")
        partners = db_geni.get_partners_from_profile(aunt_prof.get_id())
        for prof_id in partners:
            partner_prof = db_geni.get_profile_by_ID(prof_id)
            if "Aunt Other Partner" in partner_prof.nameLifespan():
                partner_prof.delete_profile()

        db.close_db()
        if os.path.exists(working_file): os.remove(working_file)
Exemplo n.º 4
0
    def test_single_match(self):
        '''
        Tests a single match in GENI
        '''
        #First we create the files for testing
        input_file = os.path.join(self.filelocation, "Rootstest.rmgc")
        working_file = os.path.join(self.filelocation, "Rootstest_sync.rmgc")

        if os.path.exists(working_file): os.remove(working_file)
        copyfile(input_file, working_file)
        ########
        #EXECUTION PART
        ########
        #Preparing the inputs
        db = database_rm(working_file)
        db_geni = geni_database_interface()

        sync_class = sync_profiles(db,
                                   db_geni,
                                   data_language="es",
                                   name_convention="spanish_surname")

        sync_class.execute_sync()

        #We delete the testing data
        db.close_db()
        if os.path.exists(working_file): os.remove(working_file)
Exemplo n.º 5
0
    def test_basic_db_function_Geni(self):
        '''
        Testing basic database functionality
        '''
        db_geni = geni_database_interface()
        prof = db_geni.get_profile_by_ID(UNCLE_ID)
        assert (UNCLE_PROF_ID in db_geni.profiles)
        assert (db_geni.get_profile_by_ID(UNCLE_PROF_ID))
        assert (prof.get_specific_event("baptism").get_accuracy() == "BETWEEN")
        assert (prof.get_specific_event("baptism").year_end == 1901)

        fam = db_geni.get_family_by_ID(FATHER_MOTHER_UNION_ID)
        assert (len(fam.union_data["partners"]) == 2)
        assert (not MARRIAGE_ID in db_geni.families)
        #Testing getting the child
        assert (db_geni.get_family_from_child(SON_PROF_ID))
        assert (MARRIAGE_ID in db_geni.families)
        #Testing getting the children
        children = db_geni.get_all_children(FATHER_PROF_ID)
        assert (len(children) == 3)
        assert (MAIN_SANDBOX_PROFILE_ID in children)
        #Checking the families where is parent the profile
        families = db_geni.get_all_family_ids_is_parent(
            MAIN_SANDBOX_PROFILE_ID)
        assert (MARRIAGE_ID in families)

        assert (WIFE_PROF_ID
                in db_geni.get_partners_from_profile(MAIN_SANDBOX_PROFILE_ID))
Exemplo n.º 6
0
 def testCousinsExecution(self):
     '''
     We will test the cousins execution in different way. Will be tested by
     number, not by person
     '''
     #Database creation
     geni_db = geni_database_interface()
     philip = profile(COUSIN_PROFILE)
     generations = 2
     
     climber = climb(geni_db)
     ancestors, anc_count, profiles = climber.get_cousins(philip, generations)
     
     total_center = 0
     total_outside = 0
     for i in range(0, generations+1):
         total_center = total_center + anc_count[i][i]
         for j in range(i+1, generations + 1):
             total_outside = total_outside + anc_count[i][j]
     assert(total_center == 7) 
     assert(total_outside == 0) 
     
     total_final = 0
     #We are counting here the number of cousing of the generation selected.
     #However, I noticed that this number varies... I selected an historical person
     #Philip IV of Spain, but apparently hundreds of years after... still new cousins appear.
     #TODO: fix this with a more stable profile, potentially from sandbox.
     for i in range(0, generations+1):
         for j in range(0, generations + 1):
             total_final = total_final + anc_count[i][j]
     assert(total_final == 32)
     assert(len(profiles) == 32)
Exemplo n.º 7
0
 def testStopWithNoAncestors(self):
     '''
     If there are no longer ancestors, the ancestor climb should stop.
     Checking if that works! This profile has only one generation available
     '''
     #Database creation
     geni_db = geni_database_interface()
     flavia = profile(FLAVIAg)
     
     climber = climb(geni_db)
     ancestors = climber.get_ancestors(flavia, 6)
     
     assert(len(ancestors) == 2)
    def testCountingOfAncestors(self):
        '''
        Testing the right calculation of ancestors. We know Philip IV was
        having duplicated ancestors, so the number will be lower than the 
        generation count.
        '''
        #Database creation
        geni_db = geni_database_interface()
        philip = profile(PHILIPIVg)

        climber = climb(geni_db)

        ancest = climber.get_ancestors(philip, 4)
        assert (len(ancest[1].keys()) == 23)
Exemplo n.º 9
0
    def test_single_match(self):
        '''
        Tests a single match in GENI
        '''
        #First we create the files for testing
        input_file = os.path.join(self.filelocation, "Rootstest.rmgc")
        working_file = os.path.join(self.filelocation, "Rootstest_sync.rmgc")

        if os.path.exists(working_file): os.remove(working_file)
        copyfile(input_file, working_file)
        ########
        #EXECUTION PART
        ########
        #Preparing the inputs
        db = database_rm(working_file)
        db_geni = geni_database_interface()

        sync_class = sync_profiles(db,
                                   db_geni,
                                   data_language="es",
                                   name_convention="spanish_surname")

        logging.basicConfig(level=logging.INFO)

        ########
        #PRE-CHECK PART
        ########
        #In RootsMagic there is not baptism
        assert ("baptism" not in db.get_profile_by_ID(2).getEventsDict())
        #The update has been done several days ago
        assert ((datetime.today() -
                 db.get_profile_by_ID(2).get_update_datetime()).days > 0)

        sync_class.execute_sync()

        ########
        #CHECKING STEP
        ########
        #Baptism should have been copied from the profile in Geni, so now it should have been created
        assert ("baptism" in db.get_profile_by_ID(2).getEventsDict())
        #The update has been done today
        assert ((datetime.today() -
                 db.get_profile_by_ID(2).get_update_datetime()).days == 0)

        #We delete the testing data
        db.close_db()
        if os.path.exists(working_file): os.remove(working_file)
Exemplo n.º 10
0
    def test_single_match(self):
        '''
        Tests a single match in GENI
        '''

        input_file = os.path.join(self.filelocation, "Rootstest.rmgc")
        working_file = os.path.join(self.filelocation, "Rootstest_match.rmgc")

        if os.path.exists(working_file): os.remove(working_file)
        copyfile(input_file, working_file)

        db = database_rm(working_file)
        db_geni = geni_database_interface()
        #Delete existing profiles from this testing area
        clean_geni_prof(db_geni)
        matcher = match_single_profile(db,
                                       db_geni,
                                       data_language="es",
                                       name_convention="spanish_surname")
        #Testing profile, no GENI. It will provide an ERROR message, but is expected
        assert (matcher.match(1) == False)
        non_matched_profiles_rm, non_matched_profiles_geni, conflict_profiles, matched_profiles = matcher.match(
            2)
        #=================================================
        #Now we check executions properly done
        #=================================================
        #Profile URL is matched
        matched_total = True
        for id_prof in [4, 5, 1]:
            prof_matched = db.get_profile_by_ID(id_prof)
            is_matched_by_geni = False
            for web_dict in prof_matched.get_all_webs():
                if (web_dict["name"] == "GENI"): is_matched_by_geni = True
            if (not is_matched_by_geni): matched_total = False
        assert (matched_total)
        #Matched is consistent
        assert (4 in matched_profiles.keys())
        assert (5 in matched_profiles.keys())
        assert (3 in matched_profiles.keys())
        assert (1 in matched_profiles.keys())
        #Secure detected conflicts
        assert (7 in conflict_profiles.keys())
        #Check not matched profiles
        assert ('profile-518' in non_matched_profiles_geni.keys())
        #No missing match in RM part
        assert (len(non_matched_profiles_rm.keys()) == 0)

        geni_detected = False
        for task in db.get_profile_by_ID(7).get_all_tasks():
            if ("GENI" in task["task_details"]): geni_detected = True
        assert (geni_detected)

        #===============================================
        # New test with different parameter
        #===============================================
        non_matched_profiles_rm2, non_matched_profiles_geni2, conflict_profiles2, matched_profiles2 = matcher.match(
            11)
        assert (12 in non_matched_profiles_rm2.keys())
        #assert(13 in non_matched_profiles_rm2.keys())
        assert ("profile-553" in non_matched_profiles_geni2.keys())
        assert ("profile-579" in non_matched_profiles_geni2.keys())
        assert (not conflict_profiles2)
        assert (10 in matched_profiles2.keys())
        #Delete existing profiles from this testing area
        clean_geni_prof(db_geni)

        db.close_db()
        if os.path.exists(working_file): os.remove(working_file)