backend/feature/add-description #63
							
								
								
									
										3
									
								
								backend/.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								backend/.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -1,6 +1,9 @@
 | 
			
		||||
# osm-cache
 | 
			
		||||
cache_XML/
 | 
			
		||||
 | 
			
		||||
# secrets
 | 
			
		||||
*secrets.yaml
 | 
			
		||||
 | 
			
		||||
# Byte-compiled / optimized / DLL files
 | 
			
		||||
__pycache__/
 | 
			
		||||
*.py[cod]
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										10062
									
								
								backend/landmarks.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10062
									
								
								backend/landmarks.json
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							@@ -1,9 +1,10 @@
 | 
			
		||||
"""Main app for backend api"""
 | 
			
		||||
 | 
			
		||||
import json
 | 
			
		||||
import logging
 | 
			
		||||
import time
 | 
			
		||||
from contextlib import asynccontextmanager
 | 
			
		||||
from fastapi import FastAPI, HTTPException, BackgroundTasks, Query
 | 
			
		||||
from fastapi.encoders import jsonable_encoder
 | 
			
		||||
 | 
			
		||||
from .logging_config import configure_logging
 | 
			
		||||
from .structs.landmark import Landmark, Toilets
 | 
			
		||||
@@ -96,6 +97,11 @@ def new_trip(preferences: Preferences,
 | 
			
		||||
    if len(landmarks) == 0 :
 | 
			
		||||
        raise HTTPException(status_code=500, detail="No landmarks were found.")
 | 
			
		||||
 | 
			
		||||
    # store landmarks in json file for debug
 | 
			
		||||
    landmarks_list = [jsonable_encoder(item) for item in landmarks]        
 | 
			
		||||
    with open('landmarks.json', 'w+') as file:
 | 
			
		||||
        json.dump(landmarks_list, file, indent=4)
 | 
			
		||||
 | 
			
		||||
    # insert start and finish to the landmarks list
 | 
			
		||||
    landmarks_short.insert(0, start_landmark)
 | 
			
		||||
    landmarks_short.append(end_landmark)
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
"""Definition of the Landmark class to handle visitable objects across the world."""
 | 
			
		||||
 | 
			
		||||
from typing import Optional, Literal
 | 
			
		||||
from typing import Optional, Literal, List
 | 
			
		||||
from uuid import uuid4, UUID
 | 
			
		||||
from pydantic import BaseModel, ConfigDict, Field
 | 
			
		||||
 | 
			
		||||
@@ -50,7 +50,7 @@ class Landmark(BaseModel) :
 | 
			
		||||
    image_url : Optional[str] = None
 | 
			
		||||
    website_url : Optional[str] = None
 | 
			
		||||
    wiki_url : Optional[str] = None
 | 
			
		||||
    description : Optional[str] = None                          # TODO future
 | 
			
		||||
    description : Optional[str] = None
 | 
			
		||||
    duration : Optional[int] = 5
 | 
			
		||||
    name_en : Optional[str] = None
 | 
			
		||||
 | 
			
		||||
@@ -69,6 +69,12 @@ class Landmark(BaseModel) :
 | 
			
		||||
    is_viewpoint : Optional[bool] = False
 | 
			
		||||
    is_place_of_worship : Optional[bool] = False
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    class Config:
 | 
			
		||||
        json_encoders = {
 | 
			
		||||
            UUID: lambda v: str(v)  # Ensure UUID is serialized as a string
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    def __str__(self) -> str:
 | 
			
		||||
        """
 | 
			
		||||
        String representation of the Landmark object.
 | 
			
		||||
 
 | 
			
		||||
@@ -11,7 +11,7 @@ def client():
 | 
			
		||||
    """Client used to call the app."""
 | 
			
		||||
    return TestClient(app)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
'''
 | 
			
		||||
def test_turckheim(client, request):    # pylint: disable=redefined-outer-name
 | 
			
		||||
    """
 | 
			
		||||
    Test n°1 : Custom test in Turckheim to ensure small villages are also supported.
 | 
			
		||||
@@ -46,8 +46,6 @@ def test_turckheim(client, request):    # pylint: disable=redefined-outer-name
 | 
			
		||||
    # Add details to report
 | 
			
		||||
    log_trip_details(request, landmarks, result['total_time'], duration_minutes)
 | 
			
		||||
 | 
			
		||||
    # for elem in landmarks :
 | 
			
		||||
    #     print(elem)
 | 
			
		||||
 | 
			
		||||
    # checks :
 | 
			
		||||
    assert response.status_code == 200  # check for successful planning
 | 
			
		||||
@@ -221,7 +219,7 @@ def test_zurich(client, request) :   # pylint: disable=redefined-outer-name
 | 
			
		||||
    assert duration_minutes*0.8 < result['total_time'], f"Trip too short: {result['total_time']} instead of {duration_minutes}"
 | 
			
		||||
    assert duration_minutes*1.2 > result['total_time'], f"Trip too long: {result['total_time']} instead of {duration_minutes}"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
'''
 | 
			
		||||
def test_paris(client, request) :   # pylint: disable=redefined-outer-name
 | 
			
		||||
    """
 | 
			
		||||
    Test n°6 : Custom test in Paris (les Halles) centre to ensure proper decision making in crowded area.
 | 
			
		||||
@@ -261,7 +259,7 @@ def test_paris(client, request) :   # pylint: disable=redefined-outer-name
 | 
			
		||||
    assert comp_time < 30, f"Computation time exceeded 30 seconds: {comp_time:.2f} seconds"
 | 
			
		||||
    assert duration_minutes*0.8 < result['total_time'], f"Trip too short: {result['total_time']} instead of {duration_minutes}"
 | 
			
		||||
    assert duration_minutes*1.2 > result['total_time'], f"Trip too long: {result['total_time']} instead of {duration_minutes}"
 | 
			
		||||
 | 
			
		||||
'''
 | 
			
		||||
 | 
			
		||||
def test_new_york(client, request) :   # pylint: disable=redefined-outer-name
 | 
			
		||||
    """
 | 
			
		||||
@@ -343,3 +341,5 @@ def test_shopping(client, request) :   # pylint: disable=redefined-outer-name
 | 
			
		||||
    assert comp_time < 30, f"Computation time exceeded 30 seconds: {comp_time:.2f} seconds"
 | 
			
		||||
    assert duration_minutes*0.8 < result['total_time'], f"Trip too short: {result['total_time']} instead of {duration_minutes}"
 | 
			
		||||
    assert duration_minutes*1.2 > result['total_time'], f"Trip too long: {result['total_time']} instead of {duration_minutes}"
 | 
			
		||||
    
 | 
			
		||||
    '''
 | 
			
		||||
							
								
								
									
										48
									
								
								status
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								status
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,48 @@
 | 
			
		||||
error: wrong number of arguments, should be from 1 to 2
 | 
			
		||||
usage: git config [<options>]
 | 
			
		||||
 | 
			
		||||
Config file location
 | 
			
		||||
    --[no-]global         use global config file
 | 
			
		||||
    --[no-]system         use system config file
 | 
			
		||||
    --[no-]local          use repository config file
 | 
			
		||||
    --[no-]worktree       use per-worktree config file
 | 
			
		||||
    -f, --[no-]file <file>
 | 
			
		||||
                          use given config file
 | 
			
		||||
    --[no-]blob <blob-id> read config from given blob object
 | 
			
		||||
 | 
			
		||||
Action
 | 
			
		||||
    --[no-]get            get value: name [value-pattern]
 | 
			
		||||
    --[no-]get-all        get all values: key [value-pattern]
 | 
			
		||||
    --[no-]get-regexp     get values for regexp: name-regex [value-pattern]
 | 
			
		||||
    --[no-]get-urlmatch   get value specific for the URL: section[.var] URL
 | 
			
		||||
    --[no-]replace-all    replace all matching variables: name value [value-pattern]
 | 
			
		||||
    --[no-]add            add a new variable: name value
 | 
			
		||||
    --[no-]unset          remove a variable: name [value-pattern]
 | 
			
		||||
    --[no-]unset-all      remove all matches: name [value-pattern]
 | 
			
		||||
    --[no-]rename-section rename section: old-name new-name
 | 
			
		||||
    --[no-]remove-section remove a section: name
 | 
			
		||||
    -l, --[no-]list       list all
 | 
			
		||||
    --[no-]fixed-value    use string equality when comparing values to 'value-pattern'
 | 
			
		||||
    -e, --[no-]edit       open an editor
 | 
			
		||||
    --[no-]get-color      find the color configured: slot [default]
 | 
			
		||||
    --[no-]get-colorbool  find the color setting: slot [stdout-is-tty]
 | 
			
		||||
 | 
			
		||||
Type
 | 
			
		||||
    -t, --[no-]type <type>
 | 
			
		||||
                          value is given this type
 | 
			
		||||
    --bool                value is "true" or "false"
 | 
			
		||||
    --int                 value is decimal number
 | 
			
		||||
    --bool-or-int         value is --bool or --int
 | 
			
		||||
    --bool-or-str         value is --bool or string
 | 
			
		||||
    --path                value is a path (file or directory name)
 | 
			
		||||
    --expiry-date         value is an expiry date
 | 
			
		||||
 | 
			
		||||
Other
 | 
			
		||||
    -z, --[no-]null       terminate values with NUL byte
 | 
			
		||||
    --[no-]name-only      show variable names only
 | 
			
		||||
    --[no-]includes       respect include directives on lookup
 | 
			
		||||
    --[no-]show-origin    show origin of config (file, standard input, blob, command line)
 | 
			
		||||
    --[no-]show-scope     show scope of config (worktree, local, global, system, command)
 | 
			
		||||
    --[no-]default <value>
 | 
			
		||||
                          with --get, use default value when missing entry
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user