backend/feature/supabase #60
							
								
								
									
										10
									
								
								.vscode/launch.json
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										10
									
								
								.vscode/launch.json
									
									
									
									
										vendored
									
									
								
							@@ -21,10 +21,16 @@
 | 
				
			|||||||
            ]
 | 
					            ]
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            "name": "Backend - tester",
 | 
					            "name": "Backend - test",
 | 
				
			||||||
            "type": "debugpy",
 | 
					            "type": "debugpy",
 | 
				
			||||||
            "request": "launch",
 | 
					            "request": "launch",
 | 
				
			||||||
            "program": "src/tester.py",
 | 
					            "module": "pytest",
 | 
				
			||||||
 | 
					            "args": [
 | 
				
			||||||
 | 
					                "src/tests",
 | 
				
			||||||
 | 
					                "--log-cli-level=DEBUG",
 | 
				
			||||||
 | 
					                "--html=report.html",
 | 
				
			||||||
 | 
					                "--self-contained-html"
 | 
				
			||||||
 | 
					            ],
 | 
				
			||||||
            "env": {
 | 
					            "env": {
 | 
				
			||||||
                "DEBUG": "true"
 | 
					                "DEBUG": "true"
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
 
 | 
				
			|||||||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							@@ -10,6 +10,8 @@ from ..payments.supabase import Supabase
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
supabase = Supabase()
 | 
					supabase = Supabase()
 | 
				
			||||||
logger = logging.getLogger(__name__)
 | 
					logger = logging.getLogger(__name__)
 | 
				
			||||||
 | 
					USER_ID = supabase.SUPABASE_TEST_USER_ID
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@pytest.fixture(scope="module")
 | 
					@pytest.fixture(scope="module")
 | 
				
			||||||
def client():
 | 
					def client():
 | 
				
			||||||
@@ -32,7 +34,7 @@ def test_turckheim(client, request):    # pylint: disable=redefined-outer-name
 | 
				
			|||||||
    response = client.post(
 | 
					    response = client.post(
 | 
				
			||||||
        "/trip/new",
 | 
					        "/trip/new",
 | 
				
			||||||
        json={
 | 
					        json={
 | 
				
			||||||
            "user_id": supabase.SUPABASE_TEST_USER_ID,
 | 
					            "user_id": USER_ID,
 | 
				
			||||||
            "preferences": {"sightseeing": {"type": "sightseeing", "score": 5},
 | 
					            "preferences": {"sightseeing": {"type": "sightseeing", "score": 5},
 | 
				
			||||||
                "nature": {"type": "nature", "score": 0},
 | 
					                "nature": {"type": "nature", "score": 0},
 | 
				
			||||||
                "shopping": {"type": "shopping", "score": 0},
 | 
					                "shopping": {"type": "shopping", "score": 0},
 | 
				
			||||||
@@ -44,8 +46,7 @@ def test_turckheim(client, request):    # pylint: disable=redefined-outer-name
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
    result = response.json()
 | 
					    result = response.json()
 | 
				
			||||||
    logger.debug(f'API response : {result}')
 | 
					    supabase.increment_credit_balance(user_id=USER_ID)
 | 
				
			||||||
    supabase.increment_credit_balance(user_id=supabase.SUPABASE_TEST_USER_ID)
 | 
					 | 
				
			||||||
    landmarks = load_trip_landmarks(client, result['first_landmark_uuid'])
 | 
					    landmarks = load_trip_landmarks(client, result['first_landmark_uuid'])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -68,7 +69,7 @@ def test_turckheim(client, request):    # pylint: disable=redefined-outer-name
 | 
				
			|||||||
    # assert 2!= 3
 | 
					    # assert 2!= 3
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
'''
 | 
					
 | 
				
			||||||
def test_bellecour(client, request) :   # pylint: disable=redefined-outer-name
 | 
					def test_bellecour(client, request) :   # pylint: disable=redefined-outer-name
 | 
				
			||||||
    """
 | 
					    """
 | 
				
			||||||
    Test n°2 : Custom test in Lyon centre to ensure proper decision making in crowded area.
 | 
					    Test n°2 : Custom test in Lyon centre to ensure proper decision making in crowded area.
 | 
				
			||||||
@@ -84,7 +85,7 @@ def test_bellecour(client, request) :   # pylint: disable=redefined-outer-name
 | 
				
			|||||||
    response = client.post(
 | 
					    response = client.post(
 | 
				
			||||||
        "/trip/new",
 | 
					        "/trip/new",
 | 
				
			||||||
        json={
 | 
					        json={
 | 
				
			||||||
            "user_id": supabase.SUPABASE_TEST_USER_ID,
 | 
					            "user_id": USER_ID,
 | 
				
			||||||
            "preferences": {"sightseeing": {"type": "sightseeing", "score": 5},
 | 
					            "preferences": {"sightseeing": {"type": "sightseeing", "score": 5},
 | 
				
			||||||
                            "nature": {"type": "nature", "score": 5},
 | 
					                            "nature": {"type": "nature", "score": 5},
 | 
				
			||||||
                            "shopping": {"type": "shopping", "score": 5},
 | 
					                            "shopping": {"type": "shopping", "score": 5},
 | 
				
			||||||
@@ -94,7 +95,7 @@ def test_bellecour(client, request) :   # pylint: disable=redefined-outer-name
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
    result = response.json()
 | 
					    result = response.json()
 | 
				
			||||||
    supabase.increment_credit_balance(user_id=supabase.SUPABASE_TEST_USER_ID)
 | 
					    supabase.increment_credit_balance(user_id=USER_ID)
 | 
				
			||||||
    landmarks = load_trip_landmarks(client, result['first_landmark_uuid'])
 | 
					    landmarks = load_trip_landmarks(client, result['first_landmark_uuid'])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Get computation time
 | 
					    # Get computation time
 | 
				
			||||||
@@ -126,7 +127,7 @@ def test_cologne(client, request) :   # pylint: disable=redefined-outer-name
 | 
				
			|||||||
    response = client.post(
 | 
					    response = client.post(
 | 
				
			||||||
        "/trip/new",
 | 
					        "/trip/new",
 | 
				
			||||||
        json={
 | 
					        json={
 | 
				
			||||||
            "user_id": supabase.SUPABASE_TEST_USER_ID,
 | 
					            "user_id": USER_ID,
 | 
				
			||||||
            "preferences": {"sightseeing": {"type": "sightseeing", "score": 5},
 | 
					            "preferences": {"sightseeing": {"type": "sightseeing", "score": 5},
 | 
				
			||||||
                            "nature": {"type": "nature", "score": 5},
 | 
					                            "nature": {"type": "nature", "score": 5},
 | 
				
			||||||
                            "shopping": {"type": "shopping", "score": 5},
 | 
					                            "shopping": {"type": "shopping", "score": 5},
 | 
				
			||||||
@@ -136,7 +137,7 @@ def test_cologne(client, request) :   # pylint: disable=redefined-outer-name
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
    result = response.json()
 | 
					    result = response.json()
 | 
				
			||||||
    supabase.increment_credit_balance(user_id=supabase.SUPABASE_TEST_USER_ID)
 | 
					    supabase.increment_credit_balance(user_id=USER_ID)
 | 
				
			||||||
    landmarks = load_trip_landmarks(client, result['first_landmark_uuid'])
 | 
					    landmarks = load_trip_landmarks(client, result['first_landmark_uuid'])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Get computation time
 | 
					    # Get computation time
 | 
				
			||||||
@@ -169,7 +170,7 @@ def test_strasbourg(client, request) :   # pylint: disable=redefined-outer-name
 | 
				
			|||||||
    response = client.post(
 | 
					    response = client.post(
 | 
				
			||||||
        "/trip/new",
 | 
					        "/trip/new",
 | 
				
			||||||
        json={
 | 
					        json={
 | 
				
			||||||
            "user_id": supabase.SUPABASE_TEST_USER_ID,
 | 
					            "user_id": USER_ID,
 | 
				
			||||||
            "preferences": {"sightseeing": {"type": "sightseeing", "score": 5},
 | 
					            "preferences": {"sightseeing": {"type": "sightseeing", "score": 5},
 | 
				
			||||||
                            "nature": {"type": "nature", "score": 5},
 | 
					                            "nature": {"type": "nature", "score": 5},
 | 
				
			||||||
                            "shopping": {"type": "shopping", "score": 5},
 | 
					                            "shopping": {"type": "shopping", "score": 5},
 | 
				
			||||||
@@ -179,7 +180,7 @@ def test_strasbourg(client, request) :   # pylint: disable=redefined-outer-name
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
    result = response.json()
 | 
					    result = response.json()
 | 
				
			||||||
    supabase.increment_credit_balance(user_id=supabase.SUPABASE_TEST_USER_ID)
 | 
					    supabase.increment_credit_balance(user_id=USER_ID)
 | 
				
			||||||
    landmarks = load_trip_landmarks(client, result['first_landmark_uuid'])
 | 
					    landmarks = load_trip_landmarks(client, result['first_landmark_uuid'])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Get computation time
 | 
					    # Get computation time
 | 
				
			||||||
@@ -212,7 +213,7 @@ def test_zurich(client, request) :   # pylint: disable=redefined-outer-name
 | 
				
			|||||||
    response = client.post(
 | 
					    response = client.post(
 | 
				
			||||||
        "/trip/new",
 | 
					        "/trip/new",
 | 
				
			||||||
        json={
 | 
					        json={
 | 
				
			||||||
            "user_id": supabase.SUPABASE_TEST_USER_ID,
 | 
					            "user_id": USER_ID,
 | 
				
			||||||
            "preferences": {"sightseeing": {"type": "sightseeing", "score": 5},
 | 
					            "preferences": {"sightseeing": {"type": "sightseeing", "score": 5},
 | 
				
			||||||
                            "nature": {"type": "nature", "score": 5},
 | 
					                            "nature": {"type": "nature", "score": 5},
 | 
				
			||||||
                            "shopping": {"type": "shopping", "score": 5},
 | 
					                            "shopping": {"type": "shopping", "score": 5},
 | 
				
			||||||
@@ -222,7 +223,7 @@ def test_zurich(client, request) :   # pylint: disable=redefined-outer-name
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
    result = response.json()
 | 
					    result = response.json()
 | 
				
			||||||
    supabase.increment_credit_balance(user_id=supabase.SUPABASE_TEST_USER_ID)
 | 
					    supabase.increment_credit_balance(user_id=USER_ID)
 | 
				
			||||||
    landmarks = load_trip_landmarks(client, result['first_landmark_uuid'])
 | 
					    landmarks = load_trip_landmarks(client, result['first_landmark_uuid'])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Get computation time
 | 
					    # Get computation time
 | 
				
			||||||
@@ -255,7 +256,7 @@ def test_paris(client, request) :   # pylint: disable=redefined-outer-name
 | 
				
			|||||||
    response = client.post(
 | 
					    response = client.post(
 | 
				
			||||||
        "/trip/new",
 | 
					        "/trip/new",
 | 
				
			||||||
        json={
 | 
					        json={
 | 
				
			||||||
            "user_id": supabase.SUPABASE_TEST_USER_ID,
 | 
					            "user_id": USER_ID,
 | 
				
			||||||
            "preferences": {"sightseeing": {"type": "sightseeing", "score": 5},
 | 
					            "preferences": {"sightseeing": {"type": "sightseeing", "score": 5},
 | 
				
			||||||
                            "nature": {"type": "nature", "score": 0},
 | 
					                            "nature": {"type": "nature", "score": 0},
 | 
				
			||||||
                            "shopping": {"type": "shopping", "score": 5},
 | 
					                            "shopping": {"type": "shopping", "score": 5},
 | 
				
			||||||
@@ -265,7 +266,7 @@ def test_paris(client, request) :   # pylint: disable=redefined-outer-name
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
    result = response.json()
 | 
					    result = response.json()
 | 
				
			||||||
    supabase.increment_credit_balance(user_id=supabase.SUPABASE_TEST_USER_ID)
 | 
					    supabase.increment_credit_balance(user_id=USER_ID)
 | 
				
			||||||
    landmarks = load_trip_landmarks(client, result['first_landmark_uuid'])
 | 
					    landmarks = load_trip_landmarks(client, result['first_landmark_uuid'])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Get computation time
 | 
					    # Get computation time
 | 
				
			||||||
@@ -298,7 +299,7 @@ def test_new_york(client, request) :   # pylint: disable=redefined-outer-name
 | 
				
			|||||||
    response = client.post(
 | 
					    response = client.post(
 | 
				
			||||||
        "/trip/new",
 | 
					        "/trip/new",
 | 
				
			||||||
        json={
 | 
					        json={
 | 
				
			||||||
            "user_id": supabase.SUPABASE_TEST_USER_ID,
 | 
					            "user_id": USER_ID,
 | 
				
			||||||
            "preferences": {"sightseeing": {"type": "sightseeing", "score": 5},
 | 
					            "preferences": {"sightseeing": {"type": "sightseeing", "score": 5},
 | 
				
			||||||
                            "nature": {"type": "nature", "score": 5},
 | 
					                            "nature": {"type": "nature", "score": 5},
 | 
				
			||||||
                            "shopping": {"type": "shopping", "score": 5},
 | 
					                            "shopping": {"type": "shopping", "score": 5},
 | 
				
			||||||
@@ -308,7 +309,7 @@ def test_new_york(client, request) :   # pylint: disable=redefined-outer-name
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
    result = response.json()
 | 
					    result = response.json()
 | 
				
			||||||
    supabase.increment_credit_balance(user_id=supabase.SUPABASE_TEST_USER_ID)
 | 
					    supabase.increment_credit_balance(user_id=USER_ID)
 | 
				
			||||||
    landmarks = load_trip_landmarks(client, result['first_landmark_uuid'])
 | 
					    landmarks = load_trip_landmarks(client, result['first_landmark_uuid'])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Get computation time
 | 
					    # Get computation time
 | 
				
			||||||
@@ -341,7 +342,7 @@ def test_shopping(client, request) :   # pylint: disable=redefined-outer-name
 | 
				
			|||||||
    response = client.post(
 | 
					    response = client.post(
 | 
				
			||||||
        "/trip/new",
 | 
					        "/trip/new",
 | 
				
			||||||
        json={
 | 
					        json={
 | 
				
			||||||
            "user_id": supabase.SUPABASE_TEST_USER_ID,
 | 
					            "user_id": USER_ID,
 | 
				
			||||||
            "preferences": {"sightseeing": {"type": "sightseeing", "score": 0},
 | 
					            "preferences": {"sightseeing": {"type": "sightseeing", "score": 0},
 | 
				
			||||||
                            "nature": {"type": "nature", "score": 0},
 | 
					                            "nature": {"type": "nature", "score": 0},
 | 
				
			||||||
                            "shopping": {"type": "shopping", "score": 5},
 | 
					                            "shopping": {"type": "shopping", "score": 5},
 | 
				
			||||||
@@ -351,7 +352,7 @@ def test_shopping(client, request) :   # pylint: disable=redefined-outer-name
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
    result = response.json()
 | 
					    result = response.json()
 | 
				
			||||||
    supabase.increment_credit_balance(user_id=supabase.SUPABASE_TEST_USER_ID)
 | 
					    supabase.increment_credit_balance(user_id=USER_ID)
 | 
				
			||||||
    landmarks = load_trip_landmarks(client, result['first_landmark_uuid'])
 | 
					    landmarks = load_trip_landmarks(client, result['first_landmark_uuid'])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Get computation time
 | 
					    # Get computation time
 | 
				
			||||||
@@ -368,4 +369,3 @@ 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 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*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}"
 | 
					    assert duration_minutes*1.2 > result['total_time'], f"Trip too long: {result['total_time']} instead of {duration_minutes}"
 | 
				
			||||||
'''
 | 
					 | 
				
			||||||
		Reference in New Issue
	
	Block a user