Esempio n. 1
0
    def test_types(self):
        one_to_one_schema = self.schema.children.get(self.one_to_one_name)
        self.assertEqual(one_to_one_schema.types[0], types.UUID())

        one_to_many_schema = self.schema.children.get(self.one_to_many_name)
        self.assertEqual(one_to_many_schema.types[0], types.ARRAY())

        many_to_many_schema = self.schema.children.get(self.many_to_many_name)
        self.assertEqual(many_to_many_schema.types[0], types.ARRAY())

        many_to_one_schema = self.schema.children.get(self.many_to_one_name)
        self.assertEqual(many_to_one_schema.types[0], types.UUID())
Esempio n. 2
0
 def __init__(self,
              response=WithChallengeClientResponse,
              children=None,
              **kwargs):
     super().__init__(
         **kwargs,
         description=('The result of a challenge-blocked method.'
                      ' Contains information relevant to the open challenge'
                      ' needed to complete the method execution.'),
         response=response,
         children=merge(
             {
                 with_challenge_constants.CHALLENGE_COMPLETE:
                 Schema(
                     description=
                     'A flag indicating whether the challenge is complete',
                     types=types.BOOLEAN(),
                 ),
                 with_challenge_constants.OPEN_CHALLENGE_ID:
                 Schema(
                     description='The ID of the open challenge',
                     types=types.UUID(),
                 ),
             },
             children,
         ),
     )
Esempio n. 3
0
 def __init__(self, Model, **kwargs):
   self.model = Model
   super().__init__(
     **kwargs,
     response=PrototypeResponse,
     types=types.UUID(),
   )
Esempio n. 4
0
 def __init__(self, **kwargs):
     super().__init__(**kwargs)
     self.children = {
         proxy_constants.ID: Schema(types=types.UUID()),
         proxy_constants.IP: Schema(),
         proxy_constants.CHANNEL: Schema(),
         proxy_constants.TRANSACTINO: Schema(types=types.ANY()),
     }
Esempio n. 5
0
 def setUp(self):
     self.test_key = 'test_key'
     self.schema = StructureSchema(children={
         self.test_key:
         Schema(
             types=types.UUID(),
             response=PropertyResponse,
         ),
     }, )
Esempio n. 6
0
 def __init__(self, Model):
     self.model = Model
     super().__init__(
         origin=lock_constants.ORIGIN,
         response=AccountSuperadminLockResponse,
         children={
             lock_constants.LOCK: Schema(types=types.BOOLEAN()),
             lock_constants.ACCOUNT_ID: Schema(types=types.UUID()),
         },
     )
Esempio n. 7
0
 def __init__(self, **kwargs):
     super().__init__(
         **kwargs,
         description=('The schema for the Challenge delete method.'),
         children={
             delete_constants.CHALLENGE_ID:
             Schema(
                 description=('The challenge ID to delete'),
                 types=types.UUID(),
             ),
         },
     )
Esempio n. 8
0
 def __init__(self, Model, **kwargs):
   self.model = Model
   super().__init__(
     **kwargs,
     description=(
       'The schema for the TransactionMatch get method.'
       ' Basic filters are available for the ID and'
       ' active status of the TransactionMatch.'
     ),
     response=TransactionMatchGetResponse,
     children={
       get_constants.TRANSACTION_REPORT_ID: Schema(
         description='Filter by the ID of the parent TransactionReport.',
         types=types.UUID(),
       ),
       get_constants.TRANSACTION_REPORT_TARGET_ADDRESS: Schema(
         description='Filter by the target address of the parent TransactionReport.',
       ),
       get_constants.TRANSACTION_REPORT_IS_ACTIVE: Schema(
         description='Filter by the active status of the parent TransactionReport.',
         types=types.BOOLEAN(),
       ),
       get_constants.TRANSACTION_MATCH_ID: Schema(
         description=(
           'The ID of the TransactionMatch in question. This value'
           ' will override any filters applied.'
         ),
         types=types.UUID(),
       ),
       transaction_match_fields.IS_NEW: Schema(
         description=(
           'Filter by the new status of the TransactionMatch.'
         ),
         types=types.BOOLEAN(),
       ),
       transaction_match_fields.BLOCK_HASH: Schema(
         description='Filter by the block hash of the TransactionMatch.',
       ),
     },
   )
Esempio n. 9
0
 def __init__(self, Model, **kwargs):
     self.model = Model
     super().__init__(
         **kwargs,
         description=('The schema for the Address get method.'),
         response=AddressGetResponse,
         children={
             get_constants.ADDRESS_ID:
             Schema(
                 description='The address ID',
                 types=types.UUID(),
             ),
         },
     )
Esempio n. 10
0
 def __init__(self, Model, **kwargs):
   self.model = Model
   super().__init__(
     **kwargs,
     description=(
       'The schema for the IP delete method.'
     ),
     origin=delete_constants.ORIGIN,
     response=IPDeleteResponse,
     children={
       delete_constants.IP_ID: Schema(
         description='The IP address ID',
         types=types.UUID(),
       ),
     },
   )
Esempio n. 11
0
 def __init__(self, Model, **kwargs):
     self.model = Model
     super().__init__(
         **kwargs,
         description=('The schema for the FeeReport delete method. The'
                      ' value given to this function is the ID of the'
                      ' FeeReport to delete.'),
         response=FeeReportDeleteResponse,
         origin=delete_constants.ORIGIN,
         children={
             delete_constants.FEE_REPORT_ID:
             Schema(
                 description=('The ID of the FeeReport object to delete.'),
                 types=types.UUID(),
             ),
         },
     )
Esempio n. 12
0
 def __init__(self,
              response=WithPaymentClientResponse,
              children=None,
              **kwargs):
     super().__init__(
         **kwargs,
         response=response,
         children=merge(
             {
                 with_payment_constants.PAYMENT_COMPLETE:
                 Schema(types=types.BOOLEAN()),
                 with_payment_constants.OPEN_PAYMENT_ID:
                 Schema(types=types.UUID()),
             },
             children,
         ),
     )
Esempio n. 13
0
 def __init__(self, Model, mode=None, **kwargs):
     super().__init__(**kwargs)
     self.non_nullable = {
         relationship.name
         for relationship in Model.objects.relationships(mode=mode)
         if (relationship.editable and not relationship.has_default()
             and not relationship.null and not relationship.one_to_many
             and not relationship.many_to_many)
     }
     self.children = {
         relationship.name: Schema(
             description=relationship.name,
             types=(types.UUID() if relationship.one_to_one
                    or relationship.many_to_one else types.ARRAY()),
         )
         for relationship in Model.objects.relationships(mode=mode)
         if relationship.editable
     }
Esempio n. 14
0
    def __init__(self, relationship, **kwargs):
        self.relationship = relationship

        if relationship.one_to_one or relationship.many_to_one:
            relationship_schema_types = [types.UUID()]
            if relationship.null:
                relationship_schema_types.append(
                    types.STRUCTURE(schema=NullableSchema(relationship), ), )
        else:
            relationship_schema_types = types.STRUCTURE(
                schema=RelationshipManySchema(relationship), )

        super().__init__(
            **kwargs,
            description=relationship.name,
            response=PropertyResponse,
            types=relationship_schema_types,
        )
Esempio n. 15
0
 def __init__(self, **kwargs):
     super().__init__(
         **kwargs,
         description=('The schema for the challenge result. Contains the'
                      ' outcome of the evaluation.'),
         children={
             respond_constants.CHALLENGE_ID:
             Schema(
                 description=
                 'The ID of the Challenge that is in the process of being verified',
                 types=types.UUID(),
             ),
             respond_constants.IS_VERIFIED:
             Schema(
                 description=
                 'A flag indicating whether the verification has been successful',
                 types=types.BOOLEAN(),
             ),
         },
     )
Esempio n. 16
0
 def __init__(self, Model, **kwargs):
   self.model = Model
   super().__init__(
     **kwargs,
     description=(
       'The schema for the IP get method. IP addresses can be fetched by'
       ' their ID. The default behaviour if no ID is included is to return'
       ' all IP addresses bound to this account.'
     ),
     origin=get_constants.ORIGIN,
     response=IPGetResponse,
     children={
       get_constants.IP_ID: Schema(
         description=(
           'The IP address ID'
         ),
         types=types.UUID(),
       ),
     },
   )
Esempio n. 17
0
 def __init__(self, **kwargs):
   super().__init__(
     **kwargs,
     description=(
       'The schema for the Payment get method.'
       ' It can be filtered by the open status of'
       ' the payment and the payment ID'
     ),
     response=PaymentGetResponse,
     children={
       get_constants.PAYMENT_ID: Schema(
         description='The payment ID',
         types=types.UUID(),
       ),
       payment_fields.IS_OPEN: Schema(
         description='The payment open status',
         types=types.BOOLEAN(),
       ),
     },
   )
Esempio n. 18
0
 def __init__(self, **kwargs):
     super().__init__(
         **kwargs,
         description=(
             'The schema for the Challenge respond method.'
             ' Processes a request based on the ID of the challenge,'
             ' returning the result of the challenge evaluation.'),
         client=ChallengeRespondClientSchema(),
         children={
             respond_constants.CHALLENGE_ID:
             Schema(
                 description='The ID of the challenge in question',
                 types=types.UUID(),
             ),
             respond_constants.CONTENT:
             Schema(description=(
                 'The decrypted text of the challenge,'
                 ' having been re-encrypted to the public'
                 ' key of the service and put into ascii armor format.'), ),
         },
     )
Esempio n. 19
0
 def __init__(self, Model, **kwargs):
     self.model = Model
     super().__init__(
         **kwargs,
         description=('The schema for the FeeReport activate method.'),
         response=FeeReportActivateResponse,
         origin=activate_constants.ORIGIN,
         children={
             activate_constants.FEE_REPORT_ID:
             Schema(
                 description='The ID of the FeeReport is question.',
                 types=types.UUID(),
             ),
             fee_report_fields.IS_ACTIVE:
             Schema(
                 description=('A boolean value that designates whether'
                              ' the report should be active.'),
                 types=types.BOOLEAN(),
             ),
         },
     )
Esempio n. 20
0
 def __init__(self, Model, **kwargs):
     self.model = Model
     super().__init__(
         **kwargs,
         description=('The schema for the FeeReport get method.'
                      ' Basic filters are available for the ID and'
                      ' active status of the FeeReport.'),
         response=FeeReportGetResponse,
         children={
             get_constants.FEE_REPORT_ID:
             Schema(
                 description='The ID of the FeeReport in question.',
                 types=types.UUID(),
             ),
             fee_report_fields.IS_ACTIVE:
             Schema(
                 description='The active status of the FeeReport.',
                 types=types.BOOLEAN(),
             ),
         },
     )
Esempio n. 21
0
 def __init__(self, **kwargs):
     super().__init__(
         **kwargs,
         description=('The schema for the Challenge get method.'
                      ' Returns instances of the Challenge class and'
                      ' includes a simple filter for the open status'
                      ' of each object.'),
         response=ChallengeGetResponse,
         children={
             get_constants.CHALLENGE_ID:
             Schema(
                 description=('The challenge ID'),
                 types=types.UUID(),
             ),
             challenge_fields.IS_OPEN:
             Schema(
                 description=('Filter the list of challenges'
                              ' by their open states.'),
                 types=types.BOOLEAN(),
             ),
         },
     )
Esempio n. 22
0
 def __init__(self, Model, **kwargs):
   self.model = Model
   super().__init__(
     **kwargs,
     description=(
       'The schema for the TransactionReport delete method. The'
       ' value given to this function is the ID of the'
       ' TransactionReport to delete. WARNING: successful execution'
       ' of this function will also cause all related TransactionMatch'
       ' objects to be deleted.'
     ),
     response=TransactionReportDeleteResponse,
     origin=delete_constants.ORIGIN,
     children={
       delete_constants.TRANSACTION_REPORT_ID: Schema(
         description=(
           'The ID of the TransactionReport object to delete.'
         ),
         types=types.UUID(),
       ),
     },
   )
Esempio n. 23
0
 def __init__(self, **kwargs):
     super().__init__(
         **kwargs,
         description=('The schema for the Subscription get method.'
                      ' Filters can be applied for the active status'
                      ' and the ID of the subscription.'),
         response=SubscriptionGetResponse,
         children={
             get_constants.SUBSCRIPTION_ID:
             Schema(
                 description=('The subscription ID'),
                 types=types.UUID(),
             ),
             subscription_fields.IS_ACTIVE:
             Schema(
                 description=
                 ('The subscription active status. If omitted, all subscriptions'
                  ' are returned.'),
                 types=types.BOOLEAN(),
             ),
         },
     )
Esempio n. 24
0
 def __init__(self, **kwargs):
     super().__init__(
         **kwargs,
         template=TemplateSchema(types=types.UUID()),
     )
Esempio n. 25
0
 def test_non_nullable_relationship_schema_types(self):
     self.assertEqual(self.non_nullable_relationship_schema.types,
                      [types.UUID()])
Esempio n. 26
0
 def test_nullable_relationship_schema_types(self):
     self.assertEqual(self.nullable_relationship_schema.types, [
         types.UUID(),
         types.STRUCTURE(),
     ])
Esempio n. 27
0
 def __init__(self, relationship, **kwargs):
     self.relationship = relationship
     super().__init__(
         **kwargs,
         types=types.UUID(),
     )
Esempio n. 28
0
 def __init__(self, **kwargs):
     super().__init__(
         **kwargs,
         response=CreateClientResponse,
         template=TemplateSchema(types=types.UUID()),
     )