예제 #1
0
파일: test_build.py 프로젝트: rmarren1/quiz
 def test_selection_set(self):
     field = Field(
         'bla',
         fdict({'q': 9}),
         selection_set=SelectionSet(
             Field('blabla'),
             Field('foobar', fdict({'qux': 'another string'})),
             Field('other', selection_set=SelectionSet(Field('baz'), )),
             InlineFragment(on=Dog,
                            selection_set=SelectionSet(
                                Field('name'), Field('bark_volume'),
                                Field('owner',
                                      selection_set=SelectionSet(
                                          Field('name'), )))),
         ))
     assert gql(field) == dedent('''
     bla(q: 9) {
       blabla
       foobar(qux: "another string")
       other {
         baz
       }
       ... on Dog {
         name
         bark_volume
         owner {
           name
         }
       }
     }
     ''').strip()
예제 #2
0
파일: test_build.py 프로젝트: rmarren1/quiz
 def test_combination(self):
     assert _.foo.bar[_.bing(param1=4.1).baz.foo_bar_bla(
         p2=None, r='')[_.height(unit='cm')].oof.qux()] == SelectionSet(
             Field('foo'),
             Field('bar',
                   selection_set=SelectionSet(
                       Field('bing', fdict({'param1': 4.1})),
                       Field('baz'),
                       Field(
                           'foo_bar_bla', fdict({
                               'p2': None,
                               'r': ''
                           }),
                           SelectionSet(
                               Field('height', fdict({'unit': 'cm'})), )),
                       Field('oof'),
                       Field('qux'),
                   )))
예제 #3
0
 def test_combination(self):
     assert _.foo.bar[_.bing(param1=4.1).baz.foo_bar_bla(
         p2=None, r="")[_.height(unit="cm")].oof.qux()] == SelectionSet(
             Field("foo"),
             Field(
                 "bar",
                 selection_set=SelectionSet(
                     Field("bing", fdict({"param1": 4.1})),
                     Field("baz"),
                     Field(
                         "foo_bar_bla",
                         fdict({
                             "p2": None,
                             "r": ""
                         }),
                         SelectionSet(Field("height", fdict({"unit":
                                                             "cm"}))),
                     ),
                     Field("oof"),
                     Field("qux"),
                 ),
             ),
         )
예제 #4
0
 def test_selection_set(self):
     field = Field(
         "bla",
         fdict({"q": 9}),
         selection_set=SelectionSet(
             Field("blabla"),
             Field("foobar", fdict({"qux": "another string"})),
             Field("other", selection_set=SelectionSet(Field("baz"))),
             InlineFragment(
                 on=Dog,
                 selection_set=SelectionSet(
                     Field("name"),
                     Field("bark_volume"),
                     Field(
                         "owner",
                         selection_set=SelectionSet(Field("name")),
                     ),
                 ),
             ),
         ),
     )
     assert (gql(field) == dedent("""
     bla(q: 9) {
       blabla
       foobar(qux: "another string")
       other {
         baz
       }
       ... on Dog {
         name
         bark_volume
         owner {
           name
         }
       }
     }
     """).strip())
예제 #5
0
 def test_hash(self):
     assert hash(Field("foo",
                       fdict({"bar":
                              3}))) == hash(Field("foo", fdict({"bar": 3})))
     assert hash(Field("bla", fdict({"bla": 4}))) != hash(Field("bla"))
예제 #6
0
 def test_argument_named_self(self):
     assert _.foo(self=4, bla=3) == SelectionSet(
         Field("foo", fdict({
             "self": 4,
             "bla": 3
         })))
예제 #7
0
파일: test_build.py 프로젝트: rmarren1/quiz
 def test_hash(self):
     assert hash(Field('foo',
                       fdict({'bar':
                              3}))) == hash(Field('foo', fdict({'bar': 3})))
     assert hash(Field('bla', fdict({'bla': 4}))) != hash(Field('bla'))
예제 #8
0
파일: test_build.py 프로젝트: rmarren1/quiz
 def test_argument_named_self(self):
     assert _.foo(self=4, bla=3) == SelectionSet(
         Field('foo', fdict({
             'self': 4,
             'bla': 3
         })))