Skip to content

Commit

Permalink
Update cidebase
Browse files Browse the repository at this point in the history
  • Loading branch information
devlinwaluja committed Oct 8, 2024
1 parent 021ba37 commit 499f7f9
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 14 deletions.
6 changes: 1 addition & 5 deletions pipeline/api.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import requests

API_URL = "https://api.data.gov.sg/v1/transport/traffic-images"


Expand Down Expand Up @@ -51,8 +52,3 @@ def extract_latlon(self, camera_id):
) # Return both longitude and latitude as a tuple
# If camera ID is not found
return f"Camera ID {camera_id} not found."





3 changes: 1 addition & 2 deletions pipeline/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@
import firebase_admin
from firebase_admin import firestore
from google.cloud.firestore import DocumentReference
from pydantic import BaseModel

from model import to_json_dict
from pydantic import BaseModel


class DatabaseClient:
Expand Down
1 change: 1 addition & 0 deletions pipeline/pipeline.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from api import APIClient
from TrafficImage import TrafficImage

if __name__ == "__main__":
apiclient = APIClient("https://api.data.gov.sg/v1/transport/traffic-images")
active_cameraIDs = apiclient.camera_id_array
Expand Down
9 changes: 5 additions & 4 deletions pipeline/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from pathlib import Path

import pytest

from api import APIClient
from TrafficImage import TrafficImage

Expand All @@ -23,7 +22,9 @@ def sample_camera_id() -> str:
# Load camera ID from a sample JSON file for testing
with open(Path(__file__).parent / "resources" / "traffic_images.json") as f:
cameras_data = json.loads(f.read())
return cameras_data["items"][0]["cameras"][0]["camera_id"] # Grab a camera_id from the file
return cameras_data["items"][0]["cameras"][0][
"camera_id"
] # Grab a camera_id from the file


def test_get_camera_ids(api: APIClient):
Expand Down Expand Up @@ -53,9 +54,9 @@ def test_traffic_image_class():
congestion_rating=None,
camera_id="camera_123",
longitude=103.851959,
latitude=1.290270
latitude=1.290270,
)

assert traffic_image.image == "some_image_url"
assert traffic_image.camera_id == "camera_123"
assert not traffic_image.processed # Ensure it's not processed initially
Expand Down
3 changes: 1 addition & 2 deletions pipeline/test_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@
from uuid import uuid4

import pytest
from pydantic import BaseModel

from db import DatabaseClient
from model import to_json_dict
from pydantic import BaseModel


class Model(BaseModel):
Expand Down
1 change: 0 additions & 1 deletion pipeline/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from pathlib import Path

from jsonschema import validate

from model import Camera, Congestion, Location, Rating, to_json_dict

CONGESTION_SCHEMA = Path(__file__).parent.parent / "schema" / "congestion.schema.json"
Expand Down

0 comments on commit 499f7f9

Please sign in to comment.