mirror of
				https://github.com/graphql-python/graphene-django.git
				synced 2025-11-04 01:47:57 +03:00 
			
		
		
		
	Add broken test
This commit is contained in:
		
							parent
							
								
									7085437a12
								
							
						
					
					
						commit
						67804fdc09
					
				
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| 
						 | 
					@ -4,6 +4,7 @@
 | 
				
			||||||
# Byte-compiled / optimized / DLL files
 | 
					# Byte-compiled / optimized / DLL files
 | 
				
			||||||
__pycache__/
 | 
					__pycache__/
 | 
				
			||||||
*.py[cod]
 | 
					*.py[cod]
 | 
				
			||||||
 | 
					.virtualenv
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# C extensions
 | 
					# C extensions
 | 
				
			||||||
*.so
 | 
					*.so
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -75,5 +75,6 @@ def test_mutations():
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    result = schema.execute(query)
 | 
					    result = schema.execute(query)
 | 
				
			||||||
 | 
					    print(result.data)
 | 
				
			||||||
    assert not result.errors
 | 
					    assert not result.errors
 | 
				
			||||||
    assert result.data == expected
 | 
					    assert result.data == expected
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -45,6 +45,7 @@ class Article(models.Model):
 | 
				
			||||||
    ], default='es')
 | 
					    ], default='es')
 | 
				
			||||||
    importance = models.IntegerField('Importance', null=True, blank=True,
 | 
					    importance = models.IntegerField('Importance', null=True, blank=True,
 | 
				
			||||||
                                     choices=[(1, u'Very important'), (2, u'Not as important')])
 | 
					                                     choices=[(1, u'Very important'), (2, u'Not as important')])
 | 
				
			||||||
 | 
					    tag = models.CharField(max_length=100)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def __str__(self):              # __unicode__ on Python 2
 | 
					    def __str__(self):              # __unicode__ on Python 2
 | 
				
			||||||
        return self.headline
 | 
					        return self.headline
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -368,6 +368,98 @@ def test_should_query_node_filtering():
 | 
				
			||||||
    assert result.data == expected
 | 
					    assert result.data == expected
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@pytest.mark.skipif(not DJANGO_FILTER_INSTALLED,
 | 
				
			||||||
 | 
					                    reason="django-filter should be installed")
 | 
				
			||||||
 | 
					def test_should_query_node_multiple_filtering():
 | 
				
			||||||
 | 
					    class ReporterType(DjangoObjectType):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        class Meta:
 | 
				
			||||||
 | 
					            model = Reporter
 | 
				
			||||||
 | 
					            interfaces = (Node, )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    class ArticleType(DjangoObjectType):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        class Meta:
 | 
				
			||||||
 | 
					            model = Article
 | 
				
			||||||
 | 
					            interfaces = (Node, )
 | 
				
			||||||
 | 
					            filter_fields = ('lang', 'tag')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    class Query(graphene.ObjectType):
 | 
				
			||||||
 | 
					        all_reporters = DjangoConnectionField(ReporterType)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    r = Reporter.objects.create(
 | 
				
			||||||
 | 
					        first_name='John',
 | 
				
			||||||
 | 
					        last_name='Doe',
 | 
				
			||||||
 | 
					        email='johndoe@example.com',
 | 
				
			||||||
 | 
					        a_choice=1
 | 
				
			||||||
 | 
					    )
 | 
				
			||||||
 | 
					    Article.objects.create(
 | 
				
			||||||
 | 
					        headline='Article Node 1',
 | 
				
			||||||
 | 
					        pub_date=datetime.date.today(),
 | 
				
			||||||
 | 
					        reporter=r,
 | 
				
			||||||
 | 
					        editor=r,
 | 
				
			||||||
 | 
					        lang='es',
 | 
				
			||||||
 | 
					        tag='one'
 | 
				
			||||||
 | 
					    )
 | 
				
			||||||
 | 
					    Article.objects.create(
 | 
				
			||||||
 | 
					        headline='Article Node 2',
 | 
				
			||||||
 | 
					        pub_date=datetime.date.today(),
 | 
				
			||||||
 | 
					        reporter=r,
 | 
				
			||||||
 | 
					        editor=r,
 | 
				
			||||||
 | 
					        lang='en',
 | 
				
			||||||
 | 
					        tag='two'
 | 
				
			||||||
 | 
					    )
 | 
				
			||||||
 | 
					    Article.objects.create(
 | 
				
			||||||
 | 
					        headline='Article Node 3',
 | 
				
			||||||
 | 
					        pub_date=datetime.date.today(),
 | 
				
			||||||
 | 
					        reporter=r,
 | 
				
			||||||
 | 
					        editor=r,
 | 
				
			||||||
 | 
					        lang='en',
 | 
				
			||||||
 | 
					        tag='three'
 | 
				
			||||||
 | 
					    )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    schema = graphene.Schema(query=Query)
 | 
				
			||||||
 | 
					    query = '''
 | 
				
			||||||
 | 
					        query NodeFilteringQuery {
 | 
				
			||||||
 | 
					            allReporters {
 | 
				
			||||||
 | 
					                edges {
 | 
				
			||||||
 | 
					                    node {
 | 
				
			||||||
 | 
					                        id
 | 
				
			||||||
 | 
					                        articles(lang: "es", tag: "two") {
 | 
				
			||||||
 | 
					                            edges {
 | 
				
			||||||
 | 
					                                node {
 | 
				
			||||||
 | 
					                                    id
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    '''
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    expected = {
 | 
				
			||||||
 | 
					        'allReporters': {
 | 
				
			||||||
 | 
					            'edges': [{
 | 
				
			||||||
 | 
					                'node': {
 | 
				
			||||||
 | 
					                    'id': 'UmVwb3J0ZXJUeXBlOjE=',
 | 
				
			||||||
 | 
					                    'articles': {
 | 
				
			||||||
 | 
					                        'edges': [{
 | 
				
			||||||
 | 
					                            'node': {
 | 
				
			||||||
 | 
					                                'id': 'QXJ0aWNsZVR5cGU6MQ=='
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        }]
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }]
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    result = schema.execute(query)
 | 
				
			||||||
 | 
					    assert not result.errors
 | 
				
			||||||
 | 
					    assert result.data == expected
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def test_should_query_filter_node_limit():
 | 
					def test_should_query_filter_node_limit():
 | 
				
			||||||
    class ReporterFilter(FilterSet):
 | 
					    class ReporterFilter(FilterSet):
 | 
				
			||||||
        limit = NumberFilter(method='filter_limit')
 | 
					        limit = NumberFilter(method='filter_limit')
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user