def test_fixed(self): field5 = fields.Fixed(5) field4 = fields.Fixed(4) self.assert_field(field5, PI, '3.14159') self.assert_field(field4, PI, '3.1416') self.assert_field(field4, 3, '3.0000') self.assert_field(field4, '03', '3.0000') self.assert_field(field4, '03.0', '3.0000')
class ProductSerializer: api = Namespace('product') product = api.model( 'product', { 'product_id': fields.String(readonly=True), 'sku': fields.String(description='Sku', max_length=30), 'name': fields.String(description='Name', min_length=5, max_length=20), 'description': fields.String( description='Description', min_length=10, max_length=40), 'stock': fields.Integer(description='Stock'), 'price': fields.Fixed(decimals=2), 'store_id': fields.String })
def generate_schema_dict(model): model_dict = {} for column in model.__table__.columns: if hasattr(model, 'private_fields') and column.name in model.private_fields: continue if column.type.python_type == int: model_dict[column.name] = fields.Integer elif column.type.python_type == str: model_dict[column.name] = fields.String elif column.type.python_type == datetime.datetime: model_dict[column.name] = fields.DateTime elif column.type.python_type == datetime.date: model_dict[column.name] = fields.Date elif column.type.python_type == datetime.time: model_dict[column.name] = fields.String elif column.type.python_type == bool: model_dict[column.name] = fields.Boolean elif column.type.python_type == decimal.Decimal: model_dict[column.name] = fields.Fixed(decimals=2) else: raise Exception(f'Unknown column type {column.type.python_type}') return model_dict
'receiveddate': fields.DateTime, 'applicantclientid': fields.Integer, 'submitterclientid': fields.Integer, 'noticeofworktype': fields.String, 'typeofpermit': fields.String, 'typeofapplication': fields.String, 'minenumber': fields.String, 'latitude': fields.Fixed(decimals=7), 'longitude': fields.Fixed(decimals=7), 'nameofproperty': fields.String, 'tenurenumbers': fields.String, 'crowngrantlotnumbers': fields.String, 'sitedirections': fields.String, 'firstaidequipmentonsite': fields.String, 'firstaidcertlevel': fields.String, 'descexplorationprogram':
from flask_restplus import fields from eve_wallet_export.api.restplus import api division = api.model( 'Wallet Division', { 'id': fields.Integer(description='Wallet division ID'), 'name': fields.String(description='Wallet division name'), 'balance': fields.Fixed(decimal=2, description=' Wallet division balance'), 'journal_uri': fields.String(description='API URI for wallet journal'), 'transactions_uri': fields.String(description='API URI for wallet transactions') }) wallet = api.model( 'Wallet info', { 'type': fields.String(description='What type of wallet (corp or char)'), 'characterID': fields.Integer(description='character ID'), 'characterName': fields.String(description='character name'), 'corporationID': fields.Integer(description='corporation ID'), 'corporationName': fields.String(description='corporation name'), 'divisions': fields.List(fields.Nested(division)) }) wallets = api.model( 'Wallets accessible with this API', { 'types':
product_model = product_namespace.model( 'Product', { 'name': fields.String(required=True, description='Product name'), 'description': fields.String(required=False, description='Product description'), 'main_image': fields.Raw(require=True, description='Product image', example={ 'public_id': 'fsfdfd', 'url': 'http://someimage.url' }), 'images': fields.List(fields.Raw(example={ 'public_id': 'fsfdfd', 'url': 'http://someimage.url' }), required=False, description='Product other images'), 'category_id': fields.Integer(required=True, description='Product category ID'), 'brand_id': fields.Integer(required=True, description='Product brand ID'), 'price': fields.Fixed(required=True, description='Product price'), 'quantity': fields.Integer( required=True, description='Product quantity', default=0) })
'long_description': fields.String }) CONTRACTED_WORK_PAYMENT_STATUS_CHANGE = api.model('ContractedWorkPaymentStatusChange', { 'contracted_work_payment_status_code': fields.String, 'note': fields.String }) CONTRACTED_WORK_PAYMENT = api.model( 'ContractedWorkPayment', { 'contracted_work_payment_id': fields.Integer, 'application_guid': fields.String, 'work_id': fields.String, 'interim_payment_status_code': fields.String, 'final_payment_status_code': fields.String, 'interim_actual_cost': fields.Fixed(decimals=2), 'final_actual_cost': fields.Fixed(decimals=2), 'interim_paid_amount': fields.Fixed(decimals=2), 'final_paid_amount': fields.Fixed(decimals=2), 'interim_total_hours_worked_to_date': fields.Fixed(decimals=2), 'final_total_hours_worked_to_date': fields.Fixed(decimals=2), 'interim_number_of_workers': fields.Integer, 'final_number_of_workers': fields.Integer, 'interim_report': fields.String, 'work_completion_date': fields.Date, 'interim_submitter_name': fields.String, 'final_submitter_name': fields.String, 'interim_payment_submission_date': fields.DateTime, 'final_payment_submission_date': fields.DateTime, 'has_interim_prfs': fields.Boolean, 'has_final_prfs': fields.Boolean,
}) RECLAMATION_INVOICE_DOCUMENT_MODEL = api.model( 'MineDocument', { 'mine_document_guid': fields.String, 'mine_guid': fields.String, 'document_manager_guid': fields.String, 'document_name': fields.String, 'upload_date': fields.Date, }) BOND = api.model( 'Bond', { 'bond_id': fields.Integer, 'bond_guid': fields.String, 'amount': fields.Fixed(decimals=2), 'bond_type_code': fields.String, 'payer_party_guid': fields.String, 'bond_status_code': fields.String, 'reference_number': fields.String, 'issue_date': fields.DateTime, 'institution_name': fields.String, 'institution_street': fields.String, 'institution_city': fields.String, 'institution_province': fields.String, 'institution_postal_code': fields.String, 'note': fields.String, 'payer': fields.Nested(BOND_PARTY), 'project_id': fields.String, 'permit_guid': fields.String(attribute='permit.permit_guid'), 'permit_no': fields.String(attribute='permit.permit_no'),
def test_with_default(self): field = fields.Fixed(default=0.5) assert not field.required assert field.__schema__ == {'type': 'number', 'default': 0.5}
def test_fixed_field_with_min_max(self): prop = field_to_property(fields.Fixed(min=0, max=5)) self.assertEqual(prop, {'type': 'number', 'minimum': 0, 'maximum': 5})
@api.doc('get_metadata') @api.marshal_with(model_meta) def get(self): """Return the metadata associated with the model""" return MODEL_META_DATA # Creating a JSON response model: https://flask-restplus.readthedocs.io/en/stable/marshalling.html#the-api-model-factory body_parts_prediction = api.model( 'body_parts_prediction', { 'part_id': fields.Integer(required=True, description='ID for the body part'), 'part_name': fields.String(required=True, description='Name of the body part'), 'score': fields.Fixed(required=True, description='The prediction score for the body part'), 'x': fields.Integer( required=True, description='X coordinate of the center point of the body part'), 'y': fields.Integer( required=True, description='Y coordinate of the center point of the body part') }) line_prediction = api.model( 'LinePrediction', { 'line': fields.List( fields.Integer( required=True,
def test_fixed_field_with_required(self): prop = field_to_property(fields.Fixed(required=True)) self.assertEqual(prop, {'type': 'number', 'required': True})
def test_fixed_field_with_readonly(self): prop = field_to_property(fields.Fixed(readonly=True)) self.assertEqual(prop, {'type': 'number', 'readOnly': True})
def test_fixed_field_with_title(self): prop = field_to_property(fields.Fixed(title='A title')) self.assertEqual(prop, {'type': 'number', 'title': 'A title'})
def test_fixed_field_with_description(self): prop = field_to_property(fields.Fixed(description='A description')) self.assertEqual(prop, { 'type': 'number', 'description': 'A description' })
return value.strftime("%Y-%m-%d") if value else None NOW_APPLICATION_EQUIPMENT = api.model( 'NOWEquipment', { 'equipment_id': fields.Integer, 'description': fields.String, 'quantity': fields.Integer, 'capacity': fields.String, }) NOW_APPLICATION_ACTIVITY_DETAIL_BASE = api.model( 'NOWApplicationActivityDetailBase', { 'activity_detail_id': fields.Integer, 'activity_type_description': fields.String, 'disturbed_area': fields.Fixed(decimals=2), 'timber_volume': fields.Fixed(decimals=2), 'number_of_sites': fields.Integer, 'width': fields.Integer, 'length': fields.Integer, 'depth': fields.Integer, 'height': fields.Integer, 'quantity': fields.Integer, 'incline': fields.Fixed(decimals=2), 'incline_unit_type_code': fields.String, 'cut_line_length': fields.Integer, 'water_quantity': fields.Integer, 'water_quantity_unit_type_code': fields.String, 'cut_line_length_unit_type_code': fields.String, 'length_unit_type_code': fields.String, 'width_unit_type_code': fields.String,
_cart_parser.add_argument("cart_lines", action="append", type=dict, required=False) """ Cart Response Model """ CartlineSchema = api.model( "CartlineSchema", { "id": fields.Integer, "product": fields.Nested( api.model( "Cartline_ProductSchema", { "id": fields.Integer, "name": fields.String, "brand": fields.String, "price": fields.Fixed(decimals=2), "images": fields.Nested( api.model( "Cartline_ImageSchema", { "image_url": fields.String, "thumbnail_url": fields.String, "main": fields.Boolean, }, ) ), }, ) ), "quantity": fields.Integer, },
def test_fixed_field_with_default(self): prop = field_to_property(fields.Fixed(default=0.5)) self.assertEqual(prop, {'type': 'number', 'default': 0.5})
'received_date': fields.Date, 'issue_date': fields.Date, 'authorization_end_date': fields.Date, 'permit_amendment_status_description': fields.String, 'permit_amendment_type_description': fields.String, 'description': fields.String, 'related_documents': fields.List(fields.Nested(PERMIT_AMENDMENT_DOCUMENT_MODEL)), 'security_total': fields.Fixed(description='Currency', decimals=2), }) PERMIT_MODEL = api.model( 'Permit', { 'permit_guid': fields.String, 'mine_guid': fields.String, 'permit_no': fields.String, 'permit_status_code': fields.String, 'permit_status_code_description': fields.String, 'permit_amendments': fields.List( fields.Nested(PERMIT_AMENDMENT_MODEL)), }) PERMIT_STATUS_CODE_MODEL = api.model( 'PermitStatusCode', {
from data_owner.services.model_service import ModelService api = Namespace('models', description='Model related operations') model_reduced_response = api.model( name='Models', model={ 'id': fields.String(required=True, description='The model identifier'), 'status': fields.String(required=True, description='The model status'), 'name': fields.String(required=True, description='The model name'), 'improvement': fields.Fixed(required=True, decimals=5, description='The model improvement'), 'cost': fields.Float(required=True, description='The model cost'), 'iterations': fields.Integer(required=True, description='Number of iterations'), 'mse': fields.Float(required=True, description='The model mse'), 'user_id': fields.String(required=True, description='The model user_id'), 'creation_date': fields.String(description='The model creation date'), 'earned': fields.Fixed(required=True, description='The earnings for training model') })
'active_ind': fields.Boolean, 'mine_tenure_type_codes': fields.List(fields.String) }) MINE_DISTURBANCE_CODE_MODEL = api.model( 'MineDisturbanceCodeModel', { 'mine_disturbance_code': fields.String, 'description': fields.String, 'active_ind': fields.Boolean, 'mine_tenure_type_codes': fields.List(fields.String) }) MINE_LOCATION_MODEL = api.model( 'MineLocation', { 'latitude': fields.Fixed(description='fixed precision decimal.', decimals=7), 'longitude': fields.Fixed(description='fixed precision decimal.', decimals=7), 'utm_easting': fields.String, 'utm_northing': fields.String, 'utm_zone_number': fields.String, 'utm_zone_letter': fields.String, 'mine_location_description': fields.String, }) MINE_DOCUMENT_MODEL = api.model(
def test_zero(self): self.assert_field(fields.Fixed(), '0', '0.00000')
def test_defaults(self): field = fields.Fixed() assert not field.required assert field.__schema__ == {'type': 'number'}
def test_nan(self): field = fields.Fixed() self.assert_field_raises(field, 'NaN')
'initial_mse': fields.Float(required=True, description='The Initial MSE of the model'), 'mse': fields.Float(required=True, description='The MSE of the model'), 'partial_MSEs': fields.List( fields.Nested(contribs), required=True, description= 'The MSE of models updated without one local trainer each'), 'iterations': fields.Integer(required=True, description='Number of iterations'), 'improvement': fields.Fixed(required=True, decimals=5, description='The model improvement'), 'mse_history': fields.List(fields.Nested(mse_history), required=True, description='The model mse history list'), 'initial_payment': fields.Fixed(required=True, decimals=1, description='The initial payment needed for training'), 'spent': fields.Fixed(required=True, decimals=2, description='The actual money spent in the training'), })
credentials = api.model( 'User Credentials', { 'email': fields.String(required=True, description='E-Mail Address'), 'password': fields.String(required=True, description='Password') }) authentication = api.model( 'User Authentication', { 'email': fields.String(required=True, description='E-Mail Address'), 'token': fields.String(required=True, description='Authentication Token') }) location = api.model( 'Location', { 'lat': fields.Fixed(decimals=7, required=True, description='Latitude'), 'lon': fields.Fixed(decimals=7, required=True, description='Longitude') }) spot = api.inherit('Parking Spot', location, {}) tariff = api.model( 'Tariff', {'pricePerMinute': fields.Arbitrary(description="Price per Minute")}) lot = api.model( 'ParkingLot', { 'lot_id': fields.String(required=True, description=''), 'name': fields.String(required=True, description=''), 'total_spots': fields.String(required=True, description=''), 'longitude':
def test_infinite(self): field = fields.Fixed() self.assert_field_raises(field, '+inf') self.assert_field_raises(field, '-inf')
description="Vara do processo.", help="Deve ser preenchido."), "num_processo_piloto": fields.String(required = True, description="Numero unico do processo piloto do agrupamento", help="Deve ser preenchido."), "sigla_tribunal_piloto": fields.String(required = True, description="Sigla para identificar o tribunal onde o numero do processo piloto é unico.", help="Deve ser preenchido."), "vara_piloto": fields.String(required = True, description="Vara do processo piloto.", help="Deve ser preenchido."), "cnpj_demandada": fields.String(required = True, description="CNPJ sem mascara da demandada.", help="Deve ser preenchido."), "valor_demanda": fields.Fixed(required = True, description="CNPJ sem mascara da demandada.", help="Deve ser preenchido.", decimals=2)}) @ns_conf.route("/source_search") class SearchSourceProcessInfo(Resource): @api.expect(busca_processo_model) def post(self): """ Faz busca de processo na base origem. """ try: json_data = request.get_json() num_processo = json_data["num_processo"] processo = Query()
if not admin: return False return sha256_crypt.verify(password_candidate, admin.password_hash) api.namespaces.clear() # get rid of default namespace api_users = api.namespace('users', description='USER operations') api_checkins = api.namespace('checkins', description='CHECKIN operations') api_cards = api.namespace('cards', description='CARD operations') api_admins = api.namespace('admins', description='ADMIN operations') users = api.model( 'Model', { 'id': fields.Integer, 'name': fields.String, 'price': fields.Fixed(description='fixed-precision decimal', decimals=2), 'balance': fields.Fixed(description='fixed-precision decimal', decimals=2) }) checkins = api.model( 'Model', { 'checkin_uid': fields.Integer, 'user_uid': fields.Integer, 'when': fields.DateTime(dt_format='rfc822'), 'amount': fields.Fixed(description='fixed-precision decimal', decimals=2), 'initiator': fields.String }) cards = api.model('Model', {