コード例 #1
0
 def test_query_one_reference_should_return_list_of_references(self):
     request: IRequest = construct_dummy_request(params={
         "host": "localhost:3449",
         "path": "/"
     })
     response = apiviews.get_references(request)
     self.__assert_valid_references(
         response, [DataReference(self.statement_reference)])
コード例 #2
0
ファイル: views.py プロジェクト: project-renard-survey/dbas
def get_references(request: Request):
    """
    Query database to get stored references from site. Generate a list with text versions of references.

    :param request: request
    :return: References assigned to the queried URL
    """
    host = request.validated["host"]
    path = request.validated["path"]
    LOG.debug("Querying references for host: {}, path: {}".format(host, path))
    refs_db: List[StatementReference] = DBDiscussionSession.query(
        StatementReference).filter_by(host=host, path=path).all()
    return {"references": [DataReference(ref) for ref in refs_db]}
コード例 #3
0
 def test_DataReference_to_json(self):
     ref = DBDiscussionSession.query(StatementReference).filter_by(statement_uid=15).first()
     sr = DataReference(ref)
     self.assertIsInstance(sr.__json__(), dict)
     for key in sr.__json__().keys():
         self.assertIn(key, ['uid', 'text', 'url'])