Skip to content

Commit

Permalink
small fix and add -vv to pytest action
Browse files Browse the repository at this point in the history
  • Loading branch information
jirathip-k committed Oct 11, 2023
1 parent 336da23 commit f5a5e1a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/App-Testing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
run: docker logs db

- name: Run pytest
run: docker exec backend pytest
run: docker exec backend pytest -vv

- name: Stop and remove Docker container
run: docker-compose -f docker-compose-dev.yaml down -v
14 changes: 11 additions & 3 deletions app/routers/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ async def search_by_query_seq_v3(
locations, route coordinates, instructions, and duration.
"""

if querys.lang != 'en-AU':
if querys.language != 'en-AU':
querys_text_pos = '_'.join(querys.query)
querys_text_neg = '_'.join(querys.negative_query)
querys_input = querys_text_pos + '|' + querys_text_neg
Expand Down Expand Up @@ -527,7 +527,8 @@ async def get_instruction(
request: Request,
route_id: int,
language: str,
r: aioredis.Redis = Depends(get_redis_feed_db)
r: aioredis.Redis = Depends(get_redis_feed_db),
db: Session = Depends(get_db),
):
if language not in ['zh-CN', 'hi-IN']:
raise LanguageNotSupportedException()
Expand All @@ -543,7 +544,14 @@ async def get_instruction(
instructions = await r.get(f"route_instructions:{route_id}")

if instructions is None:
raise LocationNotFoundException()

instructions = db.query(models.Route.instructions).filter(
models.Route.route_id == route_id).first()

instructions = "_".join(instructions[0])

if instructions is None:
raise LocationNotFoundException()

translated_instructions = translation.translate_text(
instructions,
Expand Down
9 changes: 9 additions & 0 deletions app/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ class RouteQueryV2(QuerySeq):
negative_query: list[constr(max_length=50)]
negative_similarity_threshold: float
route_type: str = "walking"
language: str = "en-AU"

@field_validator('route_type')
def check_route_type(cls, v):
Expand All @@ -225,6 +226,14 @@ def check_route_type(cls, v):
f'route_type must be one of {allowed_route_types}')
return v

@field_validator('language')
def check_language(cls, v):
allowed_languages = ['en-AU', 'zh-CN', 'hi-IN']
if v not in allowed_languages:
raise ValueError(
f'language must be one of {allowed_languages}')
return v


class SearchResult(BaseModel):
name: str
Expand Down
2 changes: 0 additions & 2 deletions app/translation.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ def translate_text(text: str, target_language: str = DEFAULT_LANG) -> dict:

target = LANG_DICT[target_language]

print(target)

result = translate_client.translate(text, target_language=target)

return result["translatedText"]

0 comments on commit f5a5e1a

Please sign in to comment.