Skip to content

Commit e0cd465

Browse files
committed
add models and mark tests to fail
1 parent 1f47f92 commit e0cd465

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

graphene_sqlalchemy/tests/models.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
String, Table, func, select)
1010
from sqlalchemy.ext.declarative import declarative_base
1111
from sqlalchemy.ext.hybrid import hybrid_property
12-
from sqlalchemy.orm import column_property, composite, mapper, relationship
12+
from sqlalchemy.orm import backref, column_property, composite, mapper, relationship
1313

1414
PetKind = Enum("cat", "dog", name="pet_kind")
1515

@@ -42,6 +42,7 @@ class Pet(Base):
4242
pet_kind = Column(PetKind, nullable=False)
4343
hair_kind = Column(Enum(HairKind, name="hair_kind"), nullable=False)
4444
reporter_id = Column(Integer(), ForeignKey("reporters.id"))
45+
legs = Column(Integer(), default=4)
4546

4647

4748
class CompositeFullName(object):
@@ -104,6 +105,14 @@ def hybrid_prop_list(self) -> List[int]:
104105
composite_prop = composite(CompositeFullName, first_name, last_name, doc="Composite")
105106

106107

108+
articles_tags_table = Table(
109+
"articles_tags",
110+
Base.metadata,
111+
Column("article_id", ForeignKey("article.id")),
112+
Column("imgae_id", ForeignKey("image.id")),
113+
)
114+
115+
107116
class Article(Base):
108117
__tablename__ = "articles"
109118
id = Column(Integer(), primary_key=True)
@@ -129,6 +138,26 @@ class ArticleReader(Base):
129138
article_id = Column(Integer(), ForeignKey("articles.id"), primary_key=True)
130139
reader_id = Column(Integer(), ForeignKey("readers.id"), primary_key=True)
131140

141+
# one-to-one relationship with image
142+
image_id = Column(Integer(), ForeignKey('image.id'), unique=True)
143+
image = relationship("Image", backref=backref("articles", uselist=False))
144+
145+
# many-to-many relationship with tags
146+
tags = relationship("Tag", secondary=articles_tags_table, backref="articles")
147+
148+
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+
132161

133162
class ReflectedEditor(type):
134163
"""Same as Editor, but using reflected table."""

graphene_sqlalchemy/tests/test_filters.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import graphene
2+
import pytest
23

34
from ..fields import SQLAlchemyConnectionField
45
from ..filters import FloatFilter
@@ -77,6 +78,7 @@ def resolve_reporters(self, _info):
7778

7879

7980
# Test a simple example of filtering
81+
@pytest.mark.xfail
8082
def test_filter_simple(session):
8183
add_test_data(session)
8284
Query = create_schema(session)
@@ -99,6 +101,7 @@ def test_filter_simple(session):
99101

100102

101103
# Test a custom filter type
104+
@pytest.mark.xfail
102105
def test_filter_custom_type(session):
103106
add_test_data(session)
104107
Query = create_schema(session)
@@ -132,6 +135,7 @@ class CustomQuery(Query, ExtraQuery):
132135
assert result == expected
133136

134137
# Test a 1:1 relationship
138+
@pytest.mark.xfail
135139
def test_filter_relationship_one_to_one(session):
136140
article = Article(headline='Hi!')
137141
image = Image(external_id=1, description="A beautiful image.")
@@ -162,6 +166,7 @@ def test_filter_relationship_one_to_one(session):
162166

163167

164168
# Test a 1:n relationship
169+
@pytest.mark.xfail
165170
def test_filter_relationship_one_to_many(session):
166171
add_test_data(session)
167172
Query = create_schema(session)
@@ -238,6 +243,7 @@ def test_filter_relationship_one_to_many(session):
238243
assert result == expected
239244

240245
# Test a n:m relationship
246+
@pytest.mark.xfail
241247
def test_filter_relationship_many_to_many(session):
242248
article1 = Article(headline='Article! Look!')
243249
article2 = Article(headline='Woah! Another!')
@@ -326,6 +332,7 @@ def test_filter_relationship_many_to_many(session):
326332

327333

328334
# Test connecting filters with "and"
335+
@pytest.mark.xfail
329336
def test_filter_logic_and(session):
330337
add_test_data(session)
331338

@@ -354,6 +361,7 @@ def test_filter_logic_and(session):
354361

355362

356363
# Test connecting filters with "or"
364+
@pytest.mark.xfail
357365
def test_filter_logic_or(session):
358366
add_test_data(session)
359367
Query = create_schema(session)
@@ -385,6 +393,7 @@ def test_filter_logic_or(session):
385393

386394

387395
# Test connecting filters with "and" and "or" together
396+
@pytest.mark.xfail
388397
def test_filter_logic_and_or(session):
389398
add_test_data(session)
390399
Query = create_schema(session)
@@ -415,5 +424,6 @@ def test_filter_logic_and_or(session):
415424

416425

417426
# TODO hybrid property
427+
@pytest.mark.xfail
418428
def test_filter_hybrid_property(session):
419429
raise NotImplementedError

0 commit comments

Comments
 (0)