Пример #1
0
    def test_multiple_suggestions(self):
        want = {
            "setNameForHome",
            "setNameForCamera",
            "setAddressForHome",
            "setNameForHomeSensor",
            "setArmedStateForHome",
        }
        got = oracle.get_valid_fields(
            'Cannot query field "NameForHome" on type "Mutation". Did you mean "setNameForHome", "setNameForCamera", "setAddressForHome", "setNameForHomeSensor", or "setArmedStateForHome"?'
        )
        self.assertEqual(got, want)

        want_2 = {"homeId", "name", "role"}
        got_2 = oracle.get_valid_fields(
            'Cannot query field "home" on type "Home". Did you mean "homeId", "name", or "role"?'
        )
        self.assertEqual(got_2, want_2)
Пример #2
0
 def test_or_suggestion(self):
     want = {"devices", "unassigned"}
     got = oracle.get_valid_fields(
         'Cannot query field "designer" on type "Query". Did you mean "devices" or "unassigned"?'
     )
     self.assertEqual(got, want)
Пример #3
0
 def test_valid_field(self):
     want = {"address"}
     got = oracle.get_valid_fields(
         'Field "address" of type "HomeAddress" must have a selection of subfields. Did you mean "address { ... }"?'
     )
     self.assertEqual(got, want)
Пример #4
0
 def test_single_suggestion(self):
     want = {"homes"}
     got = oracle.get_valid_fields(
         'Cannot query field "home" on type "Query". Did you mean "homes"?')
     self.assertEqual(got, want)