Skip to content

Commit 8f4a380

Browse files
committed
add models and mark tests to fail
1 parent e655b21 commit 8f4a380

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
@@ -6,7 +6,7 @@
66
func, select)
77
from sqlalchemy.ext.declarative import declarative_base
88
from sqlalchemy.ext.hybrid import hybrid_property
9-
from sqlalchemy.orm import column_property, composite, mapper, relationship
9+
from sqlalchemy.orm import backref, column_property, composite, mapper, relationship
1010

1111
PetKind = Enum("cat", "dog", name="pet_kind")
1212

@@ -39,6 +39,7 @@ class Pet(Base):
3939
pet_kind = Column(PetKind, nullable=False)
4040
hair_kind = Column(Enum(HairKind, name="hair_kind"), nullable=False)
4141
reporter_id = Column(Integer(), ForeignKey("reporters.id"))
42+
legs = Column(Integer(), default=4)
4243

4344

4445
class CompositeFullName(object):
@@ -76,13 +77,41 @@ def hybrid_prop(self):
7677
composite_prop = composite(CompositeFullName, first_name, last_name, doc="Composite")
7778

7879

80+
articles_tags_table = Table(
81+
"articles_tags",
82+
Base.metadata,
83+
Column("article_id", ForeignKey("article.id")),
84+
Column("imgae_id", ForeignKey("image.id")),
85+
)
86+
87+
7988
class Article(Base):
8089
__tablename__ = "articles"
8190
id = Column(Integer(), primary_key=True)
8291
headline = Column(String(100))
8392
pub_date = Column(Date())
8493
reporter_id = Column(Integer(), ForeignKey("reporters.id"))
8594

95+
# one-to-one relationship with image
96+
image_id = Column(Integer(), ForeignKey('image.id'), unique=True)
97+
image = relationship("Image", backref=backref("articles", uselist=False))
98+
99+
# many-to-many relationship with tags
100+
tags = relationship("Tag", secondary=articles_tags_table, backref="articles")
101+
102+
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+
86115

87116
class ReflectedEditor(type):
88117
"""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)