Merge pull request 'add languages to seeded test data' (#23) from add-langs into main

Reviewed-on: #23
This commit was merged in pull request #23.
This commit is contained in:
2026-01-10 18:19:40 +01:00
2 changed files with 11 additions and 11 deletions

View File

@@ -1,17 +1,18 @@
import csv
from pathlib import Path
from worblehat.models import (
Bookcase,
BookcaseItem,
BookcaseShelf,
MediaType,
Language,
MediaType,
)
CSV_FILE = Path(__file__).parent.parent.parent.parent / "data" / "arbeidsrom_smal_hylle_5.csv"
CSV_FILE = (
Path(__file__).parent.parent.parent.parent / "data" / "arbeidsrom_smal_hylle_5.csv"
)
LANGUAGE_FILE = Path(__file__).parent.parent.parent.parent / "data" / "iso639_1.csv"
def clear_db(sql_session):
@@ -32,11 +33,11 @@ def main(sql_session):
)
sql_session.add(media_type)
language = Language(
name="Norwegian",
iso639_1_code="no",
)
sql_session.add(language)
with open(LANGUAGE_FILE, newline="") as langs:
t = csv.reader(langs, delimiter=",", quotechar="|")
for row in t:
language = Language(name=row[1], iso639_1_code=row[0])
sql_session.add(language)
seed_case = Bookcase(
name="seed_case",

View File

@@ -1,14 +1,13 @@
import isbnlib
from sqlalchemy import select
from sqlalchemy.orm import Session
from .metadata_fetchers import fetch_metadata_from_multiple_sources
from ..models import (
Author,
BookcaseItem,
Language,
)
from .metadata_fetchers import fetch_metadata_from_multiple_sources
def is_valid_pvv_isbn(isbn: str) -> bool: