def test_reference_merger_1(self): #simple merge between two reference list tht have to be merged fields1 = [([('i', '1965IBVS...91....1K'), ('e', '1'), ('f', 'AUTHOR'), ('b', '1965IBVS...91....1K'), ('7', 'AUTHOR')], 'C', '5', '', 31)] fields2 = [([('i', '1982A&A...105..389V'), ('7', 'ISI'), ('b', 'Van Hamme, W.:1982, Astron. Astrophys. 105, 389'), ('e', '1'), ('f', 'ISI')], 'C', '5', '', 22)] out = [([('i', '1965IBVS...91....1K'), ('e', '1'), ('f', 'AUTHOR'), ('b', '1965IBVS...91....1K'), ('7', 'AUTHOR')], 'C', '5', '', 31), ([('i', '1982A&A...105..389V'), ('7', 'ISI'), ('b', 'Van Hamme, W.:1982, Astron. Astrophys. 105, 389'), ('e', '1'), ('f', 'ISI')], 'C', '5', '', 22)] self.assertEqual(sorted(m.references_merger(fields1, fields2, '999')), sorted(out))
def test_reference_merger_2(self): #simple merge between two incomplete lists and a complete one fields1 = [([('i', '1965IBVS...91....1K'), ('e', '1'), ('f', 'AUTHOR'), ('b', '1965IBVS...91....1K'), ('7', 'AUTHOR')], 'C', '5', '', 31), ([('i', '1982A&A...105..389V'), ('7', 'ISI'), ('b', 'Van Hamme, W.:1982, Astron. Astrophys. 105, 389'), ('e', '1'), ('f', 'ISI')], 'C', '5', '', 22)] fields2 = [([('i', '1964IBVS...54....1S'), ('e', '1'), ('f', 'OCR'), ('b', 'Strohmeier, W.:1964, Inf Bull Var. Stars No. 54'), ('7', 'OCR')], 'C', '5', '', 35)] out = [([('i', '1965IBVS...91....1K'), ('e', '1'), ('f', 'AUTHOR'), ('b', '1965IBVS...91....1K'), ('7', 'AUTHOR')], 'C', '5', '', 31), ([('i', '1982A&A...105..389V'), ('7', 'ISI'), ('b', 'Van Hamme, W.:1982, Astron. Astrophys. 105, 389'), ('e', '1'), ('f', 'ISI')], 'C', '5', '', 22), ([('i', '1964IBVS...54....1S'), ('e', '1'), ('f', 'OCR'), ('b', 'Strohmeier, W.:1964, Inf Bull Var. Stars No. 54'), ('7', 'OCR')], 'C', '5', '', 35)] self.assertEqual(sorted(m.references_merger(fields1, fields2, '999')), sorted(out))
def test_reference_merger_3(self): #merging of two incomplete lists (AUTHOR and ISI) and two complete (OCR and PUBLISHER) there must be priority between the complete lists and take_all with the other group fields1 = [([('i', '1965IBVS...91....1K'), ('e', '1'), ('f', 'AUTHOR'), ('b', '1965IBVS...91....1K'), ('7', 'AUTHOR')], 'C', '5', '', 31), ([('i', '1982A&A...105..389V'), ('7', 'ISI'), ('b', 'Van Hamme, W.:1982, Astron. Astrophys. 105, 389'), ('e', '1'), ('f', 'ISI')], 'C', '5', '', 22), ([('i', '1964IBVS...54....1S'), ('e', '1'), ('f', 'OCR'), ('b', 'Strohmeier, W.:1964, Inf Bull Var. Stars No. 54'), ('7', 'OCR')], 'C', '5', '', 35)] fields2 = [([('i', '1974IBVS..888....1C'), ('e', '1'), ('f', 'PUBLISHER'), ('b', 'Castore de Sister6, M.E., Sister6, R.F.:1974, Inf Bull Var. Stars No. 888'), ('7', 'PUBLISHER')], 'C', '5', '', 27)] out = [([('i', '1965IBVS...91....1K'), ('e', '1'), ('f', 'AUTHOR'), ('b', '1965IBVS...91....1K'), ('7', 'AUTHOR')], 'C', '5', '', 31), ([('i', '1982A&A...105..389V'), ('7', 'ISI'), ('b', 'Van Hamme, W.:1982, Astron. Astrophys. 105, 389'), ('e', '1'), ('f', 'ISI')], 'C', '5', '', 22), ([('i', '1974IBVS..888....1C'), ('e', '1'), ('f', 'PUBLISHER'), ('b', 'Castore de Sister6, M.E., Sister6, R.F.:1974, Inf Bull Var. Stars No. 888'), ('7', 'PUBLISHER')], 'C', '5', '', 27)] self.assertEqual(sorted(m.references_merger(fields1, fields2, '999')), sorted(out))
def test_reference_merger_5(self): #merging of two lists with the same reference but with the less trusted origin having better metadata and an reference extension fields1 = [([('i', '1965IBVS...91....1K'), ('e', '1'), ('f', 'AUTHOR'), ('b', '1965IBVS...91....1K'), ('7', 'AUTHOR')], 'C', '5', '', 31), ([('i', '1982A&A...105..389V'), ('7', 'ISI'), ('b', 'Van Hamme, W.:1982, Astron. Astrophys. 105, 389'), ('e', '1'), ('f', 'ISI')], 'C', '5', '', 22), ([('i', '1974IBVS..888....1C'), ('e', '1'), ('f', 'PUBLISHER'), ('b', 'Castore de Sister6, M.E., Sister6, R.F.:1974, Inf Bull Var. Stars No. 888'), ('7', 'PUBLISHER')], 'C', '5', '', 27)] fields2 = [([('i', '1965IBVS...91....1K'), ('e', '1'), ('f', 'CROSSREF'), ('b', 'Kohler, U.: Photometric Light-Curves of Southern BV-Stars 1965'), ('w', 'iop.xml'), ('7', 'CROSSREF')], 'C', '5', '', 31)] out = [([('i', '1965IBVS...91....1K'), ('e', '1'), ('f', 'AUTHOR'), ('b', 'Kohler, U.: Photometric Light-Curves of Southern BV-Stars 1965'), ('w', 'iop.xml'), ('7', 'AUTHOR')], 'C', '5', '', 31), ([('i', '1982A&A...105..389V'), ('7', 'ISI'), ('b', 'Van Hamme, W.:1982, Astron. Astrophys. 105, 389'), ('e', '1'), ('f', 'ISI')], 'C', '5', '', 22), ([('i', '1974IBVS..888....1C'), ('e', '1'), ('f', 'PUBLISHER'), ('b', 'Castore de Sister6, M.E., Sister6, R.F.:1974, Inf Bull Var. Stars No. 888'), ('7', 'PUBLISHER')], 'C', '5', '', 27)] merged = m.references_merger(fields1, fields2, '999') self.assertEqual([(sorted(elem[0]),)+elem[1:] for elem in sorted(merged)], [(sorted(elem[0]),)+elem[1:] for elem in sorted(out)])