274 lines
7.5 KiB
Python
274 lines
7.5 KiB
Python
"""
|
|
test_data
|
|
=========
|
|
|
|
Serve example data to tests.
|
|
|
|
Functions
|
|
---------
|
|
|
|
get_all_fields(model_name: str)
|
|
Return a list of field definitions for all fields that should be implemented by the given model.
|
|
|
|
get_required_fields(model_name: str)
|
|
Like get_all_fields, but only returns fields that must be set.
|
|
|
|
get_optional_fields(model_name: str)
|
|
Like get_all_fields, but only returns fields that can be omitted by a feed.
|
|
|
|
get_conditionally_required_fields(model_name: str)
|
|
Like get_all_fields, but only returns fields that must be set under certain conditions.
|
|
|
|
get_conditionally_forbidden_fields(model_name: str)
|
|
Like get_all_fields, but only returns fields that must not be set under certain conditions.
|
|
|
|
Constants
|
|
---------
|
|
|
|
data: list[dict[str,str]]
|
|
List of sets of example data.
|
|
"""
|
|
|
|
# This file is part of transport-accessibility.
|
|
# Copyright (C) 2024 Janek Kiljanski, Johannes Randerath
|
|
#
|
|
# transport-accessibility is free software: you can redistribute it and/or modify it under the terms of the
|
|
# GNU General Public License as published by the Free Software Foundation, either version 3
|
|
# of the License, or (at your option) any later version.
|
|
#
|
|
# transport-accessibility is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
# See the GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License along with transport-accessibility.
|
|
# If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
from pt_map.models import *
|
|
from pt_map.model_test_fields import field_requirements
|
|
|
|
def get_all_fields(model_name):
|
|
for m in field_requirements:
|
|
if m["model"] == model_name:
|
|
return m["fields"]
|
|
|
|
def get_required_fields(model_name):
|
|
required_fields = []
|
|
for field in get_all_fields(model_name):
|
|
if field["required"] == "true":
|
|
required_fields.append(field)
|
|
return required_fields
|
|
|
|
def get_optional_fields(model_name):
|
|
optional_fields = []
|
|
for field in get_all_fields(model_name):
|
|
if field["required"] == "false":
|
|
optional_fields.append(field)
|
|
return optional_fields
|
|
|
|
def get_conditionally_required_fields(model_name):
|
|
conditionally_required_fields = []
|
|
for field in get_all_fields(model_name):
|
|
if field["required"] == "if":
|
|
conditionally_required_fields.append(field)
|
|
return conditionally_required_fields
|
|
|
|
def get_conditionally_forbidden_fields(model_name):
|
|
conditionally_forbidden_fields = []
|
|
for field in get_all_fields(model_name):
|
|
if field.get("forbidden_if") or field.get("forbidden_if_not") or field.get("forbidden_if_eq") or field.get("forbidden_if_not_eq"):
|
|
conditionally_forbidden_fields.append(field)
|
|
return conditionally_forbidden_fields
|
|
|
|
data = [
|
|
{
|
|
"name": "Urielle Hinton",
|
|
"telephone": "1-823-274-4664",
|
|
"email": "tempor.est.ac@aol.ca",
|
|
"url": "http://instagram.com",
|
|
"pk": "PLG52MKV4VD",
|
|
"str": "nascetur ridiculus mus. Proin vel arcu eu odio",
|
|
"time": "19:53:50",
|
|
"date": "20240728",
|
|
"curcode": "HNL",
|
|
"timezone": "Europe/Paris",
|
|
"langcode": "CH",
|
|
"float": "-69.3649485824",
|
|
"int": "553828",
|
|
"color": "#f9a3a2",
|
|
"unsigned": "550",
|
|
"positive": "688",
|
|
"short": "TEJTELBBFRNFHULDITOJGGJCOSXUAT"
|
|
},
|
|
{
|
|
"name": "Gavin Church",
|
|
"telephone": "1-815-563-6268",
|
|
"email": "in.dolor@aol.org",
|
|
"url": "https://facebook.com",
|
|
"pk": "SVH10TTO8FS",
|
|
"str": "commodo hendrerit. Donec porttitor tellus non magna.",
|
|
"time": "14:36:36",
|
|
"date": "20231029",
|
|
"curcode": "XAF",
|
|
"timezone": "Europe/Berlin",
|
|
"langcode": "EL",
|
|
"float": "61.1484903424",
|
|
"int": "822377",
|
|
"color": "#01682d",
|
|
"unsigned": "477",
|
|
"positive": "373",
|
|
"short": "CBHMCOUXHTVWLKJMUZHRDFOYMUTTUQ"
|
|
},
|
|
{
|
|
"name": "Chase Frazier",
|
|
"telephone": "192-7642",
|
|
"email": "lectus.ante@outlook.com",
|
|
"url": "http://yahoo.com",
|
|
"pk": "EIL46GVS6WN",
|
|
"str": "nec, diam. Duis mi enim,",
|
|
"time": "18:18:18",
|
|
"date": "20240122",
|
|
"curcode": "BBD",
|
|
"timezone": "Europe/Berlin",
|
|
"langcode": "JX",
|
|
"float": "-31.8895552512",
|
|
"int": "567911",
|
|
"color": "#db9111",
|
|
"unsigned": "874",
|
|
"positive": "275",
|
|
"short": "MMJUPLDYDWXDUGQCWUTULEOTTIVUQT"
|
|
},
|
|
{
|
|
"name": "Abbot Peck",
|
|
"telephone": "406-5404",
|
|
"email": "cum.sociis@protonmail.edu",
|
|
"url": "https://naver.com",
|
|
"pk": "OPA71PJD1JD",
|
|
"str": "convallis ligula. Donec luctus aliquet",
|
|
"time": "16:40:51",
|
|
"date": "20241111",
|
|
"curcode": "BWP",
|
|
"timezone": "Europe/Berlin",
|
|
"langcode": "NP",
|
|
"float": "-33.0700278784",
|
|
"int": "620510",
|
|
"color": "#1e2184",
|
|
"unsigned": "15",
|
|
"positive": "865",
|
|
"short": "ZXXMJWMOHHLKFHLXSFXUGRFETRMXYE"
|
|
},
|
|
{
|
|
"name": "Anne Mcclure",
|
|
"telephone": "1-966-352-1956",
|
|
"email": "quam.quis@protonmail.net",
|
|
"url": "http://whatsapp.com",
|
|
"pk": "ZYL48JIM2TD",
|
|
"str": "Aliquam erat volutpat. Nulla",
|
|
"time": "19:12:49",
|
|
"date": "20240616",
|
|
"curcode": "PYG",
|
|
"timezone": "Europe/Berlin",
|
|
"langcode": "TD",
|
|
"float": "84.7384747008",
|
|
"int": "203213",
|
|
"color": "#b662e0",
|
|
"unsigned": "944",
|
|
"positive": "849",
|
|
"short": "FJDMMMBWCTQGQLJBPFSJQXUYQPXJEE"
|
|
},
|
|
{
|
|
"name": "Ciaran Bauer",
|
|
"telephone": "938-3385",
|
|
"email": "quam.quis@outlook.couk",
|
|
"url": "https://walmart.com",
|
|
"pk": "BUE33XNN4MW",
|
|
"str": "nec, diam. Duis mi enim, condimentum eget, volutpat ornare,",
|
|
"time": "14:23:19",
|
|
"date": "20240504",
|
|
"curcode": "USD",
|
|
"timezone": "Europe/Paris",
|
|
"langcode": "QL",
|
|
"float": "25.9520198656",
|
|
"int": "834581",
|
|
"color": "#67ef86",
|
|
"unsigned": "143",
|
|
"positive": "881",
|
|
"short": "BLQIYHRHUOSICXWQTNVNCXJHSMQQEH"
|
|
},
|
|
{
|
|
"name": "Quinn Figueroa",
|
|
"telephone": "247-1914",
|
|
"email": "fermentum.risus@outlook.couk",
|
|
"url": "https://reddit.com",
|
|
"pk": "YBT78HLB5QV",
|
|
"str": "vitae, aliquet nec,",
|
|
"time": "16:37:34",
|
|
"date": "20231212",
|
|
"curcode": "CHF",
|
|
"timezone": "Asia/Atyrau",
|
|
"langcode": "SG",
|
|
"float": "60.218623488",
|
|
"int": "331387",
|
|
"color": "#f2dd21",
|
|
"unsigned": "587",
|
|
"positive": "212",
|
|
"short": "MBIIAFIJQTDAQBUNRNSPKLCPEWRHVO"
|
|
},
|
|
{
|
|
"name": "Drew Mathews",
|
|
"telephone": "1-450-583-2435",
|
|
"email": "ipsum@protonmail.edu",
|
|
"url": "https://guardian.co.uk",
|
|
"pk": "NRR44WHI7WJ",
|
|
"str": "vehicula aliquet libero. Integer in magna. Phasellus dolor",
|
|
"time": "06:35:13",
|
|
"date": "20240418",
|
|
"curcode": "MDL",
|
|
"timezone": "Europe/Berlin",
|
|
"langcode": "MV",
|
|
"float": "83.2199729152",
|
|
"int": "479720",
|
|
"color": "#80e579",
|
|
"unsigned": "963",
|
|
"positive": "460",
|
|
"short": "TYXLDGCBDESSFDNXKEVJFTUOTZGBSJ"
|
|
},
|
|
{
|
|
"name": "Tara Ward",
|
|
"telephone": "675-7635",
|
|
"email": "egestas@icloud.ca",
|
|
"url": "http://google.com",
|
|
"pk": "LGD99AWO9PL",
|
|
"str": "lorem, sit",
|
|
"time": "02:46:45",
|
|
"date": "20240409",
|
|
"curcode": "GTQ",
|
|
"timezone": "Africa/Addis_Ababa",
|
|
"langcode": "RN",
|
|
"float": "65.537725952",
|
|
"int": "769626",
|
|
"color": "#94f271",
|
|
"unsigned": "403",
|
|
"positive": "897",
|
|
"short": "ERNQOFFSYEDQCDTNQIQWVLMYLQBLDM"
|
|
},
|
|
{
|
|
"name": "Acton Chandler",
|
|
"telephone": "903-4706",
|
|
"email": "orci.donec@aol.ca",
|
|
"url": "https://nytimes.com",
|
|
"pk": "CQX45VAV8XG",
|
|
"str": "Nunc ullamcorper, velit in aliquet lobortis, nisi",
|
|
"time": "08:55:49",
|
|
"date": "20231107",
|
|
"curcode": "JOD",
|
|
"timezone": "Europe/Paris",
|
|
"langcode": "XV",
|
|
"float": "-77.2519374848",
|
|
"int": "329555",
|
|
"color": "#fc64fc",
|
|
"unsigned": "509",
|
|
"positive": "85",
|
|
"short": "MUPETOMWOPXIRLFNUFYMQGPCHYQACV"
|
|
}
|
|
]
|