Пример #1
0
 def test_get_topic_usage_statistics(self, client, fake_auth):
     """Admin user can update a topic."""
     fake_auth.login(admin_uid)
     api_json = self._api_usage_statistics(client)
     assert list(api_json.keys()) == ['appointments', 'notes']
     assert len(api_json['appointments'])
     # Verify counts
     admin_user_id = AuthorizedUser.get_id_per_uid(uid=admin_uid)
     all_appointments = Appointment.query.filter(Appointment.deleted_at == None).all()  # noqa: E711
     all_appointments = [a.to_api_json(current_user_id=admin_user_id) for a in all_appointments]
     for topic_id, count in api_json['appointments'].items():
         topic = Topic.find_by_id(topic_id)
         matches = list(filter(lambda a: topic.topic in a['topics'], all_appointments))
         assert len(matches) == count
Пример #2
0
def undelete_topic():
    params = request.json
    topic_id = params.get('id')
    Topic.undelete(topic_id=topic_id)
    return tolerant_jsonify(Topic.find_by_id(topic_id).to_api_json())