Ejemplo n.º 1
0
def get_testdata(figures=[]):
    g = GraphicsModel(bibcode='9999BBBBBVVVVQPPPPI',
                      doi='DOI',
                      source='TEST',
                      eprint=False,
                      figures=[],
                      modtime=datetime.now())
    return g
def get_testdata(figures=[], source='TEST'):
    g = GraphicsModel(bibcode='9999BBBBBVVVVQPPPPI',
                      doi='DOI',
                      source=source,
                      eprint=False,
                      figures=figures,
                      modtime=datetime.now())
    results = json.loads(json.dumps(g, cls=AlchemyEncoder))
    return results
Ejemplo n.º 3
0
    def create_app(self):
        '''Create the wsgi application'''
        g = GraphicsModel(bibcode='bibcode',
                          doi='DOI',
                          source='TEST',
                          eprint=False,
                          figures=[],
                          modtime=datetime.now())

        app_ = app.create_app()
        app_.db.session = mock.MagicMock()

        return app_
Ejemplo n.º 4
0
def get_testdata(figures = [], thumbnails=[], source='TEST'):
    thumbs = [(f['images'][0].get('thumbnail',''),f['images'][0].get('thumnail','')) for f in figures]
    g = GraphicsModel(
        bibcode='9999BBBBBVVVVQPPPPI',
        doi='DOI',
        source=source,
        eprint=False,
        figures=figures,
        thumbnails=thumbs,
        modtime=datetime.now()
    )
    results = json.loads(json.dumps(g, cls=AlchemyEncoder))
    return results
    def test_json_encoder(self):
        '''Check if SQLAlchemy model gets translated into JSON properly'''

        g = GraphicsModel(
                bibcode='bibcode',
                doi='DOI',
                source='TEST',
                eprint=False,
                figures=[],
                modtime=datetime.now()
            )
        results = json.loads(json.dumps(g, cls=AlchemyEncoder))
        expected = {'modtime': None, 'bibcode': 'bibcode', 'source': 'TEST', 'doi': 'DOI', 'figures': [], 'eprint': False, 'id': None} 
        self.assertTrue(results==expected)