def get_daklapack_articles(token_info):
    validate_admin_access(token_info)

    with Transaction() as t:
        admin_repo = AdminRepo(t)
        dak_article_dicts = admin_repo.get_daklapack_articles()
        return jsonify(dak_article_dicts), 200
Example #2
0
 def test_get_daklapack_articles(self):
     with Transaction() as t:
         admin_repo = AdminRepo(t)
         articles = admin_repo.get_daklapack_articles()
         self.assertEqual(24, len(articles))
         first_article = articles[0]
         first_article.pop("dak_article_id")
         self.assertEqual(FIRST_DAKLAPACK_ARTICLE, first_article)
    def test_get_daklapack_articles(self):
        with Transaction() as t:
            admin_repo = AdminRepo(t)
            article_dicts_list = admin_repo.get_daklapack_articles()
            t.commit()

        # execute articles get
        response = self.client.get("/api/admin/daklapack_articles",
                                   headers=MOCK_HEADERS)

        # check response code
        self.assertEqual(200, response.status_code)

        # load the response body
        response_obj = json.loads(response.data)

        # get the first article returned and pop out its id
        first_article = response_obj[0]
        first_article.pop("dak_article_id")

        self.assertEqual(len(article_dicts_list), len(response_obj))
        self.assertEqual(FIRST_DAKLAPACK_ARTICLE, response_obj[0])