Skip to content

Commit

Permalink
fix: error after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
sushichan044 committed Oct 8, 2024
1 parent 98a8dc2 commit f466efd
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 40 deletions.
7 changes: 4 additions & 3 deletions api/birdxplorer_api/routers/data.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
from datetime import timezone
from typing import List, Union

from dateutil.parser import parse as dateutil_parse
from fastapi import APIRouter, HTTPException, Query, Request
from pydantic import HttpUrl

from birdxplorer_common.models import (
BaseModel,
LanguageIdentifier,
Expand All @@ -16,9 +20,6 @@
UserEnrollment,
)
from birdxplorer_common.storage import Storage
from dateutil.parser import parse as dateutil_parse
from fastapi import APIRouter, HTTPException, Query, Request
from pydantic import HttpUrl


class TopicListResponse(BaseModel):
Expand Down
2 changes: 1 addition & 1 deletion api/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def media_samples(media_factory: MediaFactory) -> Generator[List[Media], None, N

@fixture
def post_samples(
post_factory: PostFactory, x_user_samples: List[XUser], media_samples: List[Media],link_samples: List[Link]
post_factory: PostFactory, x_user_samples: List[XUser], media_samples: List[Media], link_samples: List[Link]
) -> Generator[List[Post], None, None]:
posts = [
post_factory.build(
Expand Down
11 changes: 4 additions & 7 deletions common/birdxplorer_common/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,14 @@
from uuid import UUID

from pydantic import BaseModel as PydanticBaseModel
from pydantic import (
ConfigDict,
GetCoreSchemaHandler,
HttpUrl,
TypeAdapter,
model_validator,
)
from pydantic import ConfigDict
from pydantic import Field as PydanticField
from pydantic import GetCoreSchemaHandler, HttpUrl, TypeAdapter, model_validator
from pydantic.alias_generators import to_camel
from pydantic.main import IncEx
from pydantic_core import core_schema

StrT = TypeVar("StrT", bound="BaseString")
IntT = TypeVar("IntT", bound="BaseInt")
FloatT = TypeVar("FloatT", bound="BaseFloat")

Expand Down
25 changes: 8 additions & 17 deletions common/birdxplorer_common/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,22 @@
from sqlalchemy.orm import DeclarativeBase, Mapped, Session, mapped_column, relationship
from sqlalchemy.types import CHAR, DECIMAL, JSON, Integer, String, Uuid

from .models import BinaryBool, LanguageIdentifier
from .models import Link as LinkModel
from .models import LinkId, Media, MediaDetails, MediaType, NonNegativeInt
from .models import Note as NoteModel
from .models import NoteId, NotesClassification, NotesHarmful, ParticipantId
from .models import Post as PostModel
from .models import PostId, SummaryString
from .models import Topic as TopicModel
from .models import (
BinaryBool,
LanguageIdentifier,
LinkId,
Media,
MediaDetails,
MediaType,
NonNegativeInt,
NoteId,
NotesClassification,
NotesHarmful,
ParticipantId,
PostId,
SummaryString,
TopicId,
TopicLabel,
TwitterTimestamp,
UserEnrollment,
UserId,
UserName,
)
from .models import Link as LinkModel
from .models import Note as NoteModel
from .models import Post as PostModel
from .models import Topic as TopicModel
from .models import XUser as XUserModel
from .settings import GlobalSettings

Expand Down
23 changes: 12 additions & 11 deletions common/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@
from collections.abc import Generator
from typing import List, Type

from dotenv import load_dotenv
from polyfactory import Use
from polyfactory.factories.pydantic_factory import ModelFactory
from polyfactory.pytest_plugin import register_fixture
from pytest import fixture
from sqlalchemy import create_engine
from sqlalchemy.engine import Engine
from sqlalchemy.exc import SQLAlchemyError
from sqlalchemy.orm import Session
from sqlalchemy.sql import text

from birdxplorer_common.models import (
Link,
Media,
Expand All @@ -26,16 +37,6 @@
TopicRecord,
XUserRecord,
)
from dotenv import load_dotenv
from polyfactory import Use
from polyfactory.factories.pydantic_factory import ModelFactory
from polyfactory.pytest_plugin import register_fixture
from pytest import fixture
from sqlalchemy import create_engine
from sqlalchemy.engine import Engine
from sqlalchemy.exc import SQLAlchemyError
from sqlalchemy.orm import Session
from sqlalchemy.sql import text


def gen_random_twitter_timestamp() -> int:
Expand Down Expand Up @@ -499,13 +500,13 @@ def post_records_sample(
post_id=post.post_id,
user_id=post.x_user_id,
text=post.text,
media_details=post.media_details,
created_at=post.created_at,
like_count=post.like_count,
repost_count=post.repost_count,
impression_count=post.impression_count,
)
sess.add(inst)

for link in post.links:
post_link_assoc = PostLinkAssociation(link_id=link.link_id, post_id=inst.post_id)
sess.add(post_link_assoc)
Expand Down
2 changes: 1 addition & 1 deletion common/tests/test_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def test_get_topic_list(
[dict(search_url=HttpUrl("https://example.com/sh3")), [2, 3]],
[dict(note_ids=[NoteId.from_str("1234567890123456781")]), [0]],
[dict(offset=1, limit=1, search_text="https://t.co/xxxxxxxxxxx/"), [2]],
[dict(with_media=True), [0, 1, 2]],
[dict(with_media=True), [0, 1, 2, 3, 4]],
[dict(post_ids=[PostId.from_str("2234567890123456781")], with_media=False), [0]],
],
)
Expand Down

0 comments on commit f466efd

Please sign in to comment.