Skip to content

Commit 32254b6

Browse files
committed
make filter tests run
1 parent e0cd465 commit 32254b6

File tree

4 files changed

+29
-19
lines changed

4 files changed

+29
-19
lines changed

graphene_sqlalchemy/filters.py

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class FloatFilter:
2+
pass

graphene_sqlalchemy/tests/models.py

+16-16
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,24 @@ def hybrid_prop_list(self) -> List[int]:
108108
articles_tags_table = Table(
109109
"articles_tags",
110110
Base.metadata,
111-
Column("article_id", ForeignKey("article.id")),
112-
Column("imgae_id", ForeignKey("image.id")),
111+
Column("article_id", ForeignKey("articles.id")),
112+
Column("tag_id", ForeignKey("tags.id")),
113113
)
114114

115115

116+
class Image(Base):
117+
__tablename__ = "images"
118+
id = Column(Integer(), primary_key=True)
119+
external_id = Column(Integer())
120+
description = Column(String(30))
121+
122+
123+
class Tag(Base):
124+
__tablename__ = "tags"
125+
id = Column(Integer(), primary_key=True)
126+
name = Column(String(30))
127+
128+
116129
class Article(Base):
117130
__tablename__ = "articles"
118131
id = Column(Integer(), primary_key=True)
@@ -139,26 +152,13 @@ class ArticleReader(Base):
139152
reader_id = Column(Integer(), ForeignKey("readers.id"), primary_key=True)
140153

141154
# one-to-one relationship with image
142-
image_id = Column(Integer(), ForeignKey('image.id'), unique=True)
155+
image_id = Column(Integer(), ForeignKey('images.id'), unique=True)
143156
image = relationship("Image", backref=backref("articles", uselist=False))
144157

145158
# many-to-many relationship with tags
146159
tags = relationship("Tag", secondary=articles_tags_table, backref="articles")
147160

148161

149-
class Image(Base):
150-
__tablename__ = "images"
151-
id = Column(Integer(), primary_key=True)
152-
external_id = Column(Integer())
153-
description = Column(String(30))
154-
155-
156-
class Tag(Base):
157-
__tablename__ = "tags"
158-
id = Column(Integer(), primary_key=True)
159-
name = Column(String(30))
160-
161-
162162
class ReflectedEditor(type):
163163
"""Same as Editor, but using reflected table."""
164164

graphene_sqlalchemy/tests/test_filters.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ class Meta:
5151
class Query(graphene.ObjectType):
5252
article = graphene.Field(ArticleType)
5353
articles = graphene.List(ArticleType)
54-
image = graphene.Field(ImageType)
55-
images = graphene.List(ImageType)
54+
# image = graphene.Field(ImageType)
55+
# images = graphene.List(ImageType)
5656
reporter = graphene.Field(ReporterType)
5757
reporters = graphene.List(ReporterType)
5858

graphene_sqlalchemy/tests/test_sort_enums.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ class Meta:
4040
"HAIR_KIND_DESC",
4141
"REPORTER_ID_ASC",
4242
"REPORTER_ID_DESC",
43+
"LEGS_ASC",
44+
"LEGS_DESC",
4345
]
4446
assert str(sort_enum.ID_ASC.value.value) == "pets.id ASC"
4547
assert str(sort_enum.ID_DESC.value.value) == "pets.id DESC"
@@ -94,6 +96,8 @@ class Meta:
9496
"PET_KIND_DESC",
9597
"HAIR_KIND_ASC",
9698
"HAIR_KIND_DESC",
99+
"LEGS_ASC",
100+
"LEGS_DESC",
97101
]
98102

99103

@@ -134,6 +138,8 @@ class Meta:
134138
"HAIR_KIND_DESC",
135139
"REPORTER_ID_ASC",
136140
"REPORTER_ID_DESC",
141+
"LEGS_ASC",
142+
"LEGS_DESC",
137143
]
138144
assert str(sort_enum.ID_ASC.value.value) == "pets.id ASC"
139145
assert str(sort_enum.ID_DESC.value.value) == "pets.id DESC"
@@ -148,7 +154,7 @@ def test_sort_argument_with_excluded_fields_in_object_type():
148154
class PetType(SQLAlchemyObjectType):
149155
class Meta:
150156
model = Pet
151-
exclude_fields = ["hair_kind", "reporter_id"]
157+
exclude_fields = ["hair_kind", "reporter_id", "legs"]
152158

153159
sort_arg = PetType.sort_argument()
154160
sort_enum = sort_arg.type._of_type
@@ -237,6 +243,8 @@ def get_symbol_name(column_name, sort_asc=True):
237243
"HairKindDown",
238244
"ReporterIdUp",
239245
"ReporterIdDown",
246+
"LegsUp",
247+
"LegsDown",
240248
]
241249
assert sort_arg.default_value == ["IdUp"]
242250

0 commit comments

Comments
 (0)