Exemple #1
0
class WriterCase(unittest.TestCase):
    def setUp(self):
        Config.parse_directory(os.path.join(basedir, 'ConfDir'))
        Config.load_user()
        self.db = DataBase('//localhost/Internal')
        self.output = cStringIO.StringIO()
        self.mapping = Config.get('ovid/mapping').data

    def test01(self):
        self.entry = Entry ( Key('TEST', 'KEY1'), get_entry('article'),
            {'journal': 'CACM',
             'number': 22,
             'volume': 123,
             'pages': '234-543'})
        self.db.add(self.entry)
        self.itera = self.db.iterator()

        writer (self.itera, self.output, self.mapping)
        print self.output.getvalue()

    def test02source (self):
        data = [ ## from cites.ovid
            {'result':
             'International Journal of Hematology. 69(2):81-88, 1999 Feb.',
             'journal': 'International Journal of Hematology',
             'volume': 69, 'number': 2, 'pages': '81-88',
             'date': Date ((1999, 2, None))},
            {'result':
             'Journal of Trauma-Injury Infection & Critical Care. 44(6):1047-1054; discussion 1054-5, 1998 Jun.',
             'journal': 'Journal of Trauma-Injury Infection & Critical Care',
             'volume': 44, 'number': 6, 'pages': '1047-1054',
             'date': Date ((1998, 6, None)),
             'other-note': 'discussion 1054-5'},
            {'result': 'Chemotherapy. 42(3):215-219, 1996 May.',
             ## date in »cites.ovid«: '1996 May-Jun' ##
             ## pages in »cites.ovid«: '215-19' ##
             'journal': 'Chemotherapy',
             'volume': 42, 'number': 3, 'pages': '215-219',
             'date': Date ((1996, 5, None))},
            {'result': 'Circulatory Shock. 18(3):193-203, 1986.',
             'journal': 'Circulatory Shock',
             'volume': 18, 'number': 3, 'pages': '193-203',
             'date': Date ('1986')},
            {'result':
             'Archives of Internal Medicine. 162(17):1961-1965, 2002 Sep 23.',
             'journal': 'Archives of Internal Medicine',
             'volume': 162, 'number': 17, 'pages': '1961-1965',
             'date': Date ((2002, 9, 23))},]

        for i in data :
            e =  Entry ( Key('TEST', 'KEY1'), get_entry('article'),
                         i)
            self.output.seek(0)
            self.output.truncate(0)
            write_source_field (self.output, e, self.mapping)
            r = self.output.getvalue()
            self.assertEqual (e['result'], r[9:-1])
    def setUp (self):


        Config.parse_directory (os.path.abspath('../ConfDir'))
        Config.load_user ()
        self.db = DataBase ('//localhost/Internal')
        self.output = cStringIO.StringIO()
        self.mapping = Config.get('ovid/mapping').data
Exemple #3
0
 def setUp(self):
     Config.parse_directory(os.path.join(basedir, 'ConfDir'))
     Config.load_user()
     self.db = DataBase('//localhost/Internal')
     self.output = cStringIO.StringIO()
     self.mapping = Config.get('ovid/mapping').data
Exemple #4
0
class WriterCase(unittest.TestCase):
    def setUp(self):
        Config.parse_directory(os.path.join(basedir, 'ConfDir'))
        Config.load_user()
        self.db = DataBase('//localhost/Internal')
        self.output = cStringIO.StringIO()
        self.mapping = Config.get('ovid/mapping').data

    def test01(self):
        self.entry = Entry(Key('TEST', 'KEY1'), get_entry('article'), {
            'journal': 'CACM',
            'number': 22,
            'volume': 123,
            'pages': '234-543'
        })
        self.db.add(self.entry)
        self.itera = self.db.iterator()

        writer(self.itera, self.output, self.mapping)
        print self.output.getvalue()

    def test02source(self):
        data = [  ## from cites.ovid
            {
                'result':
                'International Journal of Hematology. 69(2):81-88, 1999 Feb.',
                'journal': 'International Journal of Hematology',
                'volume': 69,
                'number': 2,
                'pages': '81-88',
                'date': Date((1999, 2, None))
            },
            {
                'result':
                'Journal of Trauma-Injury Infection & Critical Care. 44(6):1047-1054; discussion 1054-5, 1998 Jun.',
                'journal':
                'Journal of Trauma-Injury Infection & Critical Care',
                'volume': 44,
                'number': 6,
                'pages': '1047-1054',
                'date': Date((1998, 6, None)),
                'other-note': 'discussion 1054-5'
            },
            {
                'result': 'Chemotherapy. 42(3):215-219, 1996 May.',
                ## date in »cites.ovid«: '1996 May-Jun' ##
                ## pages in »cites.ovid«: '215-19' ##
                'journal': 'Chemotherapy',
                'volume': 42,
                'number': 3,
                'pages': '215-219',
                'date': Date((1996, 5, None))
            },
            {
                'result': 'Circulatory Shock. 18(3):193-203, 1986.',
                'journal': 'Circulatory Shock',
                'volume': 18,
                'number': 3,
                'pages': '193-203',
                'date': Date('1986')
            },
            {
                'result':
                'Archives of Internal Medicine. 162(17):1961-1965, 2002 Sep 23.',
                'journal': 'Archives of Internal Medicine',
                'volume': 162,
                'number': 17,
                'pages': '1961-1965',
                'date': Date((2002, 9, 23))
            },
        ]

        for i in data:
            e = Entry(Key('TEST', 'KEY1'), get_entry('article'), i)
            self.output.seek(0)
            self.output.truncate(0)
            write_source_field(self.output, e, self.mapping)
            r = self.output.getvalue()
            self.assertEqual(e['result'], r[9:-1])