예제 #1
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()
예제 #2
0
def test_get_technologies_names(session):
    """Verify that the get_technologies_names() return names of all technologies."""
    techs = [
        Technologies(id=12312, description='123 Tech'),
        Technologies(id=56712, description='567 Tech'),
        Technologies(id=89012, description='890 Tech')
    ]
    session.bulk_save_objects(techs)
    session.commit()
    for name in Technologies.get_technologies_names():
        assert isinstance(name, str)
    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')
 def validate_technologies(self, values):
     """Validate device technologies."""
     allowed_tech = Technologies.get_technologies_names()
     for value in values:
         if value not in allowed_tech:
             raise ValidationError("Radio Access Technology can be {0} only".format(','.join(allowed_tech)),
                                   fields=['technologies'])
 def serialize_data(self, data):
     """Serializes/transforms data before dumping."""
     technologies_list = []
     if data.device_technologies:
         technologies = DeviceTechnology.get_device_technologies(data.id)
         for tech in technologies:
             tech_type = Technologies.get_technology_by_id(tech.technology_id)
             technologies_list.append(tech_type)
     data.technologies = technologies_list
     if data.device_types_id:
         device_type = DeviceType.get_device_type_by_id(data.device_types_id)
         data.device_type = device_type
예제 #6
0
def test_get_technology_by_id(session):
    """Verify that the get_technology_by_id() returns description provided the id is given."""
    techs = [
        Technologies(id=123123, description='123 Tech'),
        Technologies(id=567123, description='567 Tech'),
        Technologies(id=890123, description='890 Tech')
    ]
    session.bulk_save_objects(techs)
    session.commit()
    assert Technologies.get_technology_by_id(123123) == '123 Tech'
    assert Technologies.get_technology_by_id(567123) == '567 Tech'
    assert Technologies.get_technology_by_id(890123) == '890 Tech'
    assert Technologies.get_technology_by_id(283802818388) is None
    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')
예제 #8
0
def test_get_technology_id(session):
    """Verify that the get_technology_id() returns
    correct id of the technology in the table provided
    technology type.
    """
    # insert data
    techs = [
        Technologies(id=123, description='123 Tech'),
        Technologies(id=567, description='567 Tech'),
        Technologies(id=890, description='890 Tech')
    ]
    session.bulk_save_objects(techs)
    session.commit()
    assert Technologies.get_technology_id('123 Tech') == 123
    assert Technologies.get_technology_id('567 Tech') == 567
    assert Technologies.get_technology_id('890 Tech') == 890
    assert Technologies.get_technology_id('hdheukkslkl') is None
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
 def __init__(self, reg_device_id, technology):
     """Constructor."""
     self.reg_device_id = reg_device_id
     self.technology_id = Technologies.get_technology_id(technology)