Skip to content

Commit 124a66b

Browse files
committed
make filter tests run
1 parent 8f4a380 commit 124a66b

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
@@ -80,11 +80,24 @@ def hybrid_prop(self):
8080
articles_tags_table = Table(
8181
"articles_tags",
8282
Base.metadata,
83-
Column("article_id", ForeignKey("article.id")),
84-
Column("imgae_id", ForeignKey("image.id")),
83+
Column("article_id", ForeignKey("articles.id")),
84+
Column("tag_id", ForeignKey("tags.id")),
8585
)
8686

8787

88+
class Image(Base):
89+
__tablename__ = "images"
90+
id = Column(Integer(), primary_key=True)
91+
external_id = Column(Integer())
92+
description = Column(String(30))
93+
94+
95+
class Tag(Base):
96+
__tablename__ = "tags"
97+
id = Column(Integer(), primary_key=True)
98+
name = Column(String(30))
99+
100+
88101
class Article(Base):
89102
__tablename__ = "articles"
90103
id = Column(Integer(), primary_key=True)
@@ -93,26 +106,13 @@ class Article(Base):
93106
reporter_id = Column(Integer(), ForeignKey("reporters.id"))
94107

95108
# one-to-one relationship with image
96-
image_id = Column(Integer(), ForeignKey('image.id'), unique=True)
109+
image_id = Column(Integer(), ForeignKey('images.id'), unique=True)
97110
image = relationship("Image", backref=backref("articles", uselist=False))
98111

99112
# many-to-many relationship with tags
100113
tags = relationship("Tag", secondary=articles_tags_table, backref="articles")
101114

102115

103-
class Image(Base):
104-
__tablename__ = "images"
105-
id = Column(Integer(), primary_key=True)
106-
external_id = Column(Integer())
107-
description = Column(String(30))
108-
109-
110-
class Tag(Base):
111-
__tablename__ = "tags"
112-
id = Column(Integer(), primary_key=True)
113-
name = Column(String(30))
114-
115-
116116
class ReflectedEditor(type):
117117
"""Same as Editor, but using reflected table."""
118118

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)