def get(self):
        """GET method handler for server-configs."""
        technologies = Technologies.get_technologies()
        device_types = DeviceType.get_device_types()
        status_types = Status.get_status_types()

        system_configs = {
            'label': 'automate_imei_request',
            'flag': app.config['AUTOMATE_IMEI_CHECK']
        },\
        {
            'label': 'overwrite_device_info',
            'flag': app.config['USE_GSMA_DEVICE_INFO']
        }

        documents = {
            'registration': Documents.get_documents('registration'),
            'de_registration': Documents.get_documents('deregistration')
        }

        response = ServerConfigSchema().dump(dict(technologies=technologies,
                                                  documents=documents,
                                                  status_types=status_types,
                                                  device_types=device_types,
                                                  system_config=system_configs)).data

        return Response(json.dumps(response), status=200, mimetype='application/json')
Beispiel #2
0
def test_get_technologies(session):
    """Verify that the get_technologies returns all the technologies in the database."""
    techs = [
        Technologies(id=1231, description='123 Tech'),
        Technologies(id=5671, description='567 Tech'),
        Technologies(id=8901, description='890 Tech')
    ]
    session.bulk_save_objects(techs)
    session.commit()
    assert Technologies.get_technologies()
    def get(self):
        """GET method handler for server-configs."""
        technologies = Technologies.get_technologies()
        device_types = DeviceType.get_device_types()
        status_types = Status.get_status_types()
        documents = {
            'registration': Documents.get_documents('registration'),
            'de_registration': Documents.get_documents('deregistration')
        }

        response = ServerConfigSchema().dump(dict(technologies=technologies,
                                                  documents=documents,
                                                  status_types=status_types,
                                                  device_types=device_types)).data
        return Response(json.dumps(response), status=200, mimetype='application/json')
def test_server_config_api(flask_app, db):  # pylint: disable=unused-argument
    """To verify that the server config apis response is correct as
    per data in database.
    """
    # get data from database
    status_types = Status.get_status_types()
    device_types = DeviceType.get_device_types()
    technologies = Technologies.get_technologies()
    documents = {
        'registration': Documents.get_documents('registration'),
        'de_registration': Documents.get_documents('deregistration')
    }
    expected_response = ServerConfigsSchema().dump(dict(technologies=technologies,
                                                        documents=documents,
                                                        status_types=status_types,
                                                        device_types=device_types)).data

    rv = flask_app.get(SERVER_CONFIGS)
    assert rv.status_code == 200
    data = json.loads(rv.data.decode('utf-8'))
    assert data == expected_response