Beispiel #1
0
def test_no_schema_exception():
    with pytest.raises(AssertionError) as exc_info:
        client = Client()
        client.validate("")
    assert "Cannot validate the document locally, you need to pass a schema." in str(
        exc_info.value
    )
class SmokeTest():

  def __init__(self, query, expected, query_fragment = None):
    self.query = query
    self.expected = expected
    self.query_fragment = query_fragment

    headers = {"Authorization": "Bearer %s" % auth_token}
    headers = {"x-api-key": auth_token}
    transport = RequestsHTTPTransport(url=api_url, headers=headers, use_json=True)

    self._client = Client(transport=transport,
            fetch_schema_from_transport=True)

  def execute(self):

    qry = self.query
    if self.query_fragment:
        qry = self.query_fragment + '\n\n' + self.query

    response = 'Didnt run'
    
    try:
      gql_query = gql(qry)
      self._client.validate(gql_query)
      response = self._client.execute(gql_query)
    except Exception as e:
      print(e)

    # print(response)

    if not response == self.expected:
        print("query", qry)
        print()
        print("expected", self.expected)
        print()
        print('response', response)
        assert 0
Beispiel #3
0
def test_backcompat(validator_client: Client, query_str: str):
    validator_client.validate(gql(query_str))
Beispiel #4
0
def test_no_schema_exception():
    with pytest.raises(Exception) as exc_info:
        client = Client()
        client.validate('')
    assert "Cannot validate locally the document, you need to pass a schema." in str(
        exc_info.value)