Skip to content

Commit

Permalink
Chore: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aaltat committed Jun 1, 2024
1 parent e431b83 commit 86ce105
Show file tree
Hide file tree
Showing 5 changed files with 1,075 additions and 0 deletions.
21 changes: 21 additions & 0 deletions atest/json_lib.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import json
from pathlib import Path

from robot.api import logger


def compare_translations(file: Path):
with Path(__file__).parent.parent.joinpath(
"robotframework_seleniumlibrary_translation_fi", "translation.json"
).open("r") as file_object:
expected_data = json.load(file_object)
expected_keywords = [kw["name"] for kw in expected_data.values()]
logger.info(f"expected_keywords: {expected_keywords}")
with file.open("r") as file_object:
data = json.load(file_object)
keywords = data["keywords"]
for keyword in keywords:
logger.info(keyword)
name = keyword["name"]
name = name.replace(" ", "_").lower()
assert name in expected_keywords, f"name '{name}' not in {expected_keywords}"
22 changes: 22 additions & 0 deletions atest/translation.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
*** Settings ***
Library Browser language=FI
Library Process
Library OperatingSystem
Library json_lib.py

*** Test Cases ***
Translation Works With Translation
Uusi Sivu https://github.com/MarketSquare/robotframework-browser-translation-fi

LibDoc Works With Translation
[Setup] Remove File ${CURDIR}/Browser.json
${json_kw_speck} = Join Path ${CURDIR} Browser.json
${cmd} = Join Command Line
... python
... -m
... robot.libdoc
... --format=json
... Browser::language=FI
... ${json_kw_speck}
Run Process ${cmd} shell=True
Compare Translations ${json_kw_speck}
28 changes: 28 additions & 0 deletions robotframework_seleniumlibrary_translation_fi/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright 2024- Robot Framework Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from pathlib import Path
from typing import TypedDict

__version__ = "0.1.0"


class Language(TypedDict):
language: str
path: str


def get_language() -> Language:
folder = Path(__file__).parent

return {"language": "fi", "path": str(folder / "translation.json")}
Loading

0 comments on commit 86ce105

Please sign in to comment.