You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
519 B
Python

from urllib.parse import urljoin
import requests
from apitesting import BASE_URL
TODOS_URL = urljoin(BASE_URL, 'todos')
def get_todos():
"""Returns a list of JSON todo elements"""
response = requests.get(TODOS_URL)
if response.ok:
return response
else:
return None
def get_uncompleted_todos():
response = get_todos()
if response is None:
return []
else:
todos = response.json()
return [todo for todo in todos if todo.get('completed') is False]