profusion / sgqlc

Simple GraphQL Client
https://sgqlc.readthedocs.io/
ISC License
506 stars 85 forks source link

Failed tests in sgqlc/types/__init__.py and sgqlc/operation/__init__.py #241

Open mcepl opened 10 months ago

mcepl commented 10 months ago

🐜 Bug Report

When running the test suite these four tests fail:

[   13s] FAILED sgqlc/operation/__init__.py::sgqlc.operation
[   13s] FAILED sgqlc/types/__init__.py::sgqlc.types
[   13s] FAILED sgqlc/types/__init__.py::sgqlc.types.Field.__bytes__
[   13s] FAILED sgqlc/types/__init__.py::sgqlc.types.Schema.__getattr__

Expected Behavior

Current Behavior

[   13s] =================================== FAILURES ===================================
[   13s] __________________________ [doctest] sgqlc.operation ___________________________
[   13s] 1483 #0: number
[   13s] 1484 
[   13s] 1485 Given a :class:`Selector` one can query a **selection** given its alias:
[   13s] 1486 
[   13s] 1487 >>> op = Operation(Query)
[   13s] 1488 >>> op.repository(id='repo1').issues.number()
[   13s] 1489 number
[   13s] 1490 >>> op.repository(id='repo2', __alias__='alias').issues.title()
[   13s] 1491 title
[   13s] 1492 >>> type(op['repository'])  # it's the selector, not a selection!
[   13s] Expected:
[   13s]     <class 'sgqlc.operation.__init__.Selector'>
[   13s] Got:
[   13s]     <class 'sgqlc.operation.Selector'>
[   13s] 
[   13s] /home/abuild/rpmbuild/BUILD/sgqlc-16.3/sgqlc/operation/__init__.py:1492: DocTestFailure
[   13s] ____________________________ [doctest] sgqlc.types _____________________________
[   13s] 157 aInt: Int
[   13s] 158 >>> TypeUsingPython.a_int.name
[   13s] 159 'a_int'
[   13s] 160 >>> TypeUsingPython.a_int.graphql_name  # auto-generated from name
[   13s] 161 'aInt'
[   13s] 162 >>> TypeUsingPython.a_int.type  # always a :mod:`sgqlc.types` class
[   13s] 163 scalar Int
[   13s] 164 >>> TypeUsingPython.__schema__ is global_schema
[   13s] 165 True
[   13s] 166 >>> global_schema  # or repr(Schema), prints out GraphQL!
[   13s] Differences (unified diff with -expected +actual):
[   13s]     @@ -5,4 +5,63 @@
[   13s]        scalar Boolean
[   13s]        scalar ID
[   13s]     +  scalar Time
[   13s]     +  scalar Date
[   13s]     +  scalar DateTime
[   13s]     +  interface Node {
[   13s]     +    id: ID!
[   13s]     +  }
[   13s]     +  type PageInfo {
[   13s]     +    endCursor: String
[   13s]     +    startCursor: String
[   13s]     +    hasNextPage: Boolean!
[   13s]     +    hasPreviousPage: Boolean!
[   13s]     +  }
[   13s]     +  scalar UUID
[   13s]     +  interface Actor {
[   13s]     +    login: String!
[   13s]     +  }
[   13s]     +  type User implements Actor {
[   13s]     +    login: String!
[   13s]     +    name: String
[   13s]     +  }
[   13s]     +  type Organization implements Actor {
[   13s]     +    login: String!
[   13s]     +    location: String
[   13s]     +  }
[   13s]     +  type ActorConnection {
[   13s]     +    actors(login: String!): [Actor!]
[   13s]     +  }
[   13s]     +  type Assignee {
[   13s]     +    email: String!
[   13s]     +  }
[   13s]     +  union UserOrAssignee = User | Assignee
[   13s]     +  type Issue {
[   13s]     +    number: Int!
[   13s]     +    title: String!
[   13s]     +    body: String
[   13s]     +    reporter: User!
[   13s]     +    assigned: UserOrAssignee
[   13s]     +    commenters: ActorConnection
[   13s]     +  }
[   13s]     +  input ReporterFilterInput {
[   13s]     +    nameContains: String
[   13s]     +  }
[   13s]     +  input IssuesFilter {
[   13s]     +    reporter: [ReporterFilterInput]
[   13s]     +    startDate: DateTime!
[   13s]     +    endDate: DateTime
[   13s]     +  }
[   13s]     +  type Repository {
[   13s]     +    id: ID
[   13s]     +    name: String!
[   13s]     +    owner: Actor!
[   13s]     +    issues(titleContains: String, reporterLogin: String, filter: IssuesFilter): [Issue!]
[   13s]     +  }
[   13s]     +  type Query {
[   13s]     +    repository(id: ID!): Repository
[   13s]     +  }
[   13s]     +  type Mutation {
[   13s]     +    addIssue(repositoryId: ID!, title: String!, body: String): Issue
[   13s]     +  }
[   13s]        type TypeUsingPython {
[   13s]          aInt: Int
[   13s] 
[   13s] /home/abuild/rpmbuild/BUILD/sgqlc-16.3/sgqlc/types/__init__.py:166: DocTestFailure
[   13s] ____________________ [doctest] sgqlc.types.Field.__bytes__ _____________________
[   13s] 2609 Prints GraphQL without indentation.
[   13s] 2610 
[   13s] 2611         >>> print(repr(global_schema.TypeUsingFields.many))
[   13s] UNEXPECTED EXCEPTION: AttributeError('TypeUsingFields')
[   13s] Traceback (most recent call last):
[   13s]   File "/home/abuild/rpmbuild/BUILD/sgqlc-16.3/sgqlc/types/__init__.py", line 760, in __getattr__
[   13s]     return self.__all[key]
[   13s] KeyError: 'TypeUsingFields'
[   13s] The above exception was the direct cause of the following exception:
[   13s] Traceback (most recent call last):
[   13s]   File "/usr/lib64/python3.9/doctest.py", line 1334, in __run
[   13s]     exec(compile(example.source, filename, "single",
[   13s]   File "<doctest sgqlc.types.Field.__bytes__[0]>", line 1, in <module>
[   13s]   File "/home/abuild/rpmbuild/BUILD/sgqlc-16.3/sgqlc/types/__init__.py", line 762, in __getattr__
[   13s]     raise AttributeError(key) from exc
[   13s] AttributeError: TypeUsingFields
[   13s] /home/abuild/rpmbuild/BUILD/sgqlc-16.3/sgqlc/types/__init__.py:2611: UnexpectedException
[   13s] ___________________ [doctest] sgqlc.types.Schema.__getattr__ ___________________
[   13s] 731         >>> global_schema.scalar['Int']
[   13s] 732         scalar Int
[   13s] 733         >>> global_schema.scalar.UnknownTypeName  # doctest: +ELLIPSIS
[   13s] 734         Traceback (most recent call last):
[   13s] 735           ...
[   13s] 736         AttributeError: ... has no field UnknownTypeName
[   13s] 737         >>> global_schema.type.TypeUsingPython  # doctest: +ELLIPSIS
[   13s] 738         type TypeUsingPython {
[   13s] 739         ...
[   13s] 740         >>> for t in global_schema.type.values():  # doctest: +ELLIPSIS
[   13s] Differences (unified diff with -expected +actual):
[   13s]     @@ -1,11 +1,63 @@
[   13s]     +type PageInfo {
[   13s]     +  endCursor: String
[   13s]     +  startCursor: String
[   13s]     +  hasNextPage: Boolean!
[   13s]     +  hasPreviousPage: Boolean!
[   13s]     +}
[   13s]     +type User implements Actor {
[   13s]     +  login: String!
[   13s]     +  name: String
[   13s]     +}
[   13s]     +type Organization implements Actor {
[   13s]     +  login: String!
[   13s]     +  location: String
[   13s]     +}
[   13s]     +type ActorConnection {
[   13s]     +  actors(login: String!): [Actor!]
[   13s]     +}
[   13s]     +type Assignee {
[   13s]     +  email: String!
[   13s]     +}
[   13s]     +type Issue {
[   13s]     +  number: Int!
[   13s]     +  title: String!
[   13s]     +  body: String
[   13s]     +  reporter: User!
[   13s]     +  assigned: UserOrAssignee
[   13s]     +  commenters: ActorConnection
[   13s]     +}
[   13s]     +type Repository {
[   13s]     +  id: ID
[   13s]     +  name: String!
[   13s]     +  owner: Actor!
[   13s]     +  issues(titleContains: String, reporterLogin: String, filter: IssuesFilter): [Issue!]
[   13s]     +}
[   13s]     +type Query {
[   13s]     +  repository(id: ID!): Repository
[   13s]     +}
[   13s]     +type Mutation {
[   13s]     +  addIssue(repositoryId: ID!, title: String!, body: String): Issue
[   13s]     +}
[   13s]      type TypeUsingPython {
[   13s]     -...
[   13s]     -type TypeUsingSGQLC {
[   13s]     -...
[   13s]     -type TypeUsingFields {
[   13s]     -...
[   13s]     -type MyOtherType {
[   13s]     -...
[   13s]     +  aInt: Int
[   13s]     +  aFloat: Float
[   13s]     +  aString: String
[   13s]     +  aBoolean: Boolean
[   13s]     +  aId: ID
[   13s]     +}
[   13s]     +type MyTypeWithArgument {
[   13s]     +  a(argName: Int): String
[   13s]     +  b(arg: Int): String
[   13s]     +  c(arg: Int): String
[   13s]     +  d(arg: Int = 1): String
[   13s]     +}
[   13s]      type MyType {
[   13s]     -...
[   13s]     +  a(argument1: String): Int
[   13s]     +  b(argument1: String): Int
[   13s]      }
[   13s]     +type TypeWithIface implements SomeIface {
[   13s]     +  i: Int
[   13s]     +}
[   13s]     +type MyTypeWithScalar {
[   13s]     +  v: Scalar
[   13s]     +}
[   13s] 
[   13s] /home/abuild/rpmbuild/BUILD/sgqlc-16.3/sgqlc/types/__init__.py:740: DocTestFailure
[   13s] =========================== short test summary info ============================
[   13s] FAILED sgqlc/operation/__init__.py::sgqlc.operation
[   13s] FAILED sgqlc/types/__init__.py::sgqlc.types
[   13s] FAILED sgqlc/types/__init__.py::sgqlc.types.Field.__bytes__
[   13s] FAILED sgqlc/types/__init__.py::sgqlc.types.Schema.__getattr__
[   13s] ========================= 4 failed, 90 passed in 0.33s =========================

Context (Environment)

Complete build log with the list of all packages used and steps taken to reproduce.