Ejemplo n.º 1
0
    def test_dates(self):
        '''We want to use only UTC dates'''
        app = self.app

        with app.session_scope() as session:
            rec = Records(bibcode='foo', created='2009-09-03T20:56:35.450686Z')
            session.add(rec)
            rec.updated = utils.get_date()
            session.commit()

            r = session.query(Records).first()
            assert r.updated.tzname() == 'UTC'
Ejemplo n.º 2
0
    def test_dates(self):
        '''We want to use only UTC dates'''
        
        with self.assertRaisesRegexp(Exception, 'ValueError'):
            with app.session_scope() as session:
                rec = Records(bibcode='foo', created='2009-09-03T20:56:35.450686Z')
                session.add(rec)
                rec.updated = datetime.now()
                session.commit()

        with app.session_scope() as session:
            rec = Records(bibcode='foo', created='2009-09-03T20:56:35.450686Z')
            session.add(rec)
            rec.updated = get_date()
            session.commit()
Ejemplo n.º 3
0
    def test_models(self):
        """Check serialization into JSON"""
        
        claim = ClaimsLog(bibcode='foo', orcidid='bar',
                          created='2009-09-03T20:56:35.450686Z')
        self.assertDictEqual(claim.toJSON(),
             {'status': None, 'bibcode': 'foo', 'created': '2009-09-03T20:56:35.450686+00:00', 'provenance': 'None', 'orcidid': 'bar', 'id': None})
        
        ainfo = AuthorInfo(orcidid='bar',
                          created='2009-09-03T20:56:35.450686Z')
        
        self.assertDictEqual(ainfo.toJSON(),
             {'status': None, 'updated': None, 'name': None, 'created': '2009-09-03T20:56:35.450686+00:00', 'facts': {}, 'orcidid': 'bar', 'id': None, 'account_id': None})
        
        rec = Records(bibcode='foo', created='2009-09-03T20:56:35.450686Z')

        self.assertDictEqual(rec.toJSON(),
             {'bibcode': 'foo', 'created': '2009-09-03T20:56:35.450686+00:00', 'updated': None, 'processed': None, 'claims': {}, 'id': None, 'authors': []})
        
        with self.assertRaisesRegexp(Exception, 'IntegrityError'):
            with app.session_scope() as session:
                c = ClaimsLog(bibcode='foo', orcidid='bar', status='hey')
                session.add(c)
                session.commit()
        
        for s in ['blacklisted', 'postponed']:
            with app.session_scope() as session:
                session.add(AuthorInfo(orcidid='bar' + s, status=s))
                session.commit()
        
        with self.assertRaisesRegexp(Exception, 'IntegrityError'):
            with app.session_scope() as session:
                c = AuthorInfo(orcidid='bar', status='hey')
                session.add(c)
                session.commit()
        
        for s in ['claimed', 'updated', 'removed', 'unchanged', '#full-import']:
            with app.session_scope() as session:
                session.add(ClaimsLog(bibcode='foo'+s, orcidid='bar', status=s))
                session.commit()
Ejemplo n.º 4
0
    def test_models(self):
        """Check serialization into JSON"""

        app = self.app
        claim = ClaimsLog(bibcode='foo',
                          orcidid='bar',
                          created='2009-09-03T20:56:35.450686Z')
        self.assertDictEqual(
            claim.toJSON(), {
                'status': None,
                'bibcode': 'foo',
                'created': '2009-09-03T20:56:35.450686+00:00',
                'provenance': 'None',
                'orcidid': 'bar',
                'id': None
            })

        ainfo = AuthorInfo(orcidid='bar',
                           created='2009-09-03T20:56:35.450686Z')

        self.assertDictEqual(
            ainfo.toJSON(), {
                'status': None,
                'updated': None,
                'name': None,
                'created': '2009-09-03T20:56:35.450686+00:00',
                'facts': {},
                'orcidid': 'bar',
                'id': None,
                'account_id': None
            })

        rec = Records(bibcode='foo', created='2009-09-03T20:56:35.450686Z')

        self.assertDictEqual(
            rec.toJSON(), {
                'bibcode': 'foo',
                'created': '2009-09-03T20:56:35.450686+00:00',
                'updated': None,
                'processed': None,
                'claims': {},
                'id': None,
                'authors': []
            })

        with self.assertRaisesRegexp(Exception, 'IntegrityError'):
            with app.session_scope() as session:
                c = ClaimsLog(bibcode='foo', orcidid='bar', status='hey')
                session.add(c)
                session.commit()

        for s in ['blacklisted', 'postponed']:
            with app.session_scope() as session:
                session.add(AuthorInfo(orcidid='bar' + s, status=s))
                session.commit()

        with self.assertRaisesRegexp(Exception, 'IntegrityError'):
            with app.session_scope() as session:
                c = AuthorInfo(orcidid='bar', status='hey')
                session.add(c)
                session.commit()

        for s in [
                'claimed', 'updated', 'removed', 'unchanged', '#full-import'
        ]:
            with app.session_scope() as session:
                session.add(
                    ClaimsLog(bibcode='foo' + s, orcidid='bar', status=s))
                session.commit()