示例#1
0
 def test_results(self, schema, page, query, paginator):
     with app.test_request_context():
         data = schema.dump(page).data
     results = data['results']
     assert len(results) == paginator.page_size
     first_author = page.contents[0]
     author_schema = serializers.AuthorSchema()
     expected = author_schema.dump(first_author).data
     assert results[0]['_id'] == expected['_id']
示例#2
0
 def test_results(self, schema, page, query, paginator):
     with app.test_request_context():
         data = schema.dump(page).data
     results = data['results']
     assert len(results) == paginator.page_size
     first_author = page.contents[0]
     author_schema = serializers.AuthorSchema()
     expected = author_schema.dump(first_author).data
     assert results[0]['_id'] == expected['_id']
示例#3
0
 def test_article_schema_basic_fields(self, schema, article):
     with app.test_request_context():
         data = schema.dump(article).data
         expected_url = url_for('article', article_id=article._id, _external=True)
     assert data['url'] == expected_url
     assert data['_id'] == article._id
     assert data['record'] == article.record
     assert data['date'] == article.date
     assert data['pmid'] == article.pmid
     assert data['doi'] == article.doi
示例#4
0
 def test_author_schema_fields(self, schema, author):
     with app.test_request_context():
         data = schema.dump(author).data
         expected_url = url_for('author', author_id=author._id, _external=True)
     assert data['url'] == expected_url
     assert data['_id'] == author._id
     assert data['full'] == author._full
     assert data['first'] == author.first
     assert data['middle'] == author.middle
     assert data['suffix'] == author.suffix
示例#5
0
 def test_article_schema_basic_fields(self, schema, article):
     with app.test_request_context():
         data = schema.dump(article).data
         expected_url = url_for('article',
                                article_id=article._id,
                                _external=True)
     assert data['url'] == expected_url
     assert data['_id'] == article._id
     assert data['record'] == article.record
     assert data['date'] == article.date
     assert data['pmid'] == article.pmid
     assert data['doi'] == article.doi
示例#6
0
 def test_author_schema_fields(self, schema, author):
     with app.test_request_context():
         data = schema.dump(author).data
         expected_url = url_for('author',
                                author_id=author._id,
                                _external=True)
     assert data['url'] == expected_url
     assert data['_id'] == author._id
     assert data['full'] == author._full
     assert data['first'] == author.first
     assert data['middle'] == author.middle
     assert data['suffix'] == author.suffix
示例#7
0
 def test_has_pages(self, schema, page, query, paginator):
     with app.test_request_context():
         data = schema.dump(page).data
     assert '?page_num=1' in data['prev']
     assert '?page_num=3' in data['next']
     assert data['count'] == query.count()
示例#8
0
 def test_has_pages(self, schema, page, query, paginator):
     with app.test_request_context():
         data = schema.dump(page).data
     assert '?page_num=1' in data['prev']
     assert '?page_num=3' in data['next']
     assert data['count'] == query.count()