Exemplo n.º 1
0
class WifiJobDocument(CommonJobDocument):
    wifi_api = WifiApiField(required=True)
    wifi_channels = ArrayField(WiFiChanelField())
    wifi_types = ArrayField(WiFiTypeField())
    wifi_nbr_retrial = NumberField(minimum=0, multiple=1)
    wifi_max_result_per_scan = NumberField(minimum=0, multiple=1)
    wifi_timeout = NumberField(minimum=0, multiple=1)
    wifi_mode = WifiModeField()
Exemplo n.º 2
0
 class User(Document):
     login = StringField()
     friends = ArrayField(
         Var({
             'db_role': db_role_friends_field,
             'request_role': request_role_friends_field,
         }))
Exemplo n.º 3
0
class JobsDocument(Document):
    infinite_loops = BooleanField()
    jobs = ArrayField(
        OneOfField(fields=[
            DocumentField(WifiJobDocument),
            DocumentField(GnssAutonomousDocument),
            DocumentField(GnssAssistedDocument),
        ]))
Exemplo n.º 4
0
class GnssAutonomousDocument(CommonJobDocument):
    gnss_autonomous_option = GnssOptionField()
    gnss_autonomous_capture_mode = GnssCaptureModeField()
    gnss_autonomous_nb_satellite = NumberField(multiple_of=1,
                                               minimum=0,
                                               maximum=255)
    gnss_autonomous_antenna_selection = GnssAntennaSelectionField()
    gnss_autonomous_constellations = ArrayField(GnssConstellationField())
Exemplo n.º 5
0
class CheckEntry(Document):
    check_actor = StringField(required=True)
    check_action = StringField()
    status = StringField(required=True, enum=['PASS', 'FAIL'])
    summary = StringField(required=True)
    params = ArrayField(items=StringField(),
                        unique_items=True,
                        additional_items=False)
Exemplo n.º 6
0
def test_error():
    db_role_friends_field = ArrayField((StringField(), None))
    request_role_friends_field = ArrayField(StringField())

    class User(Document):
        login = StringField()
        friends = ArrayField(
            Var({
                'db_role': db_role_friends_field,
                'request_role': request_role_friends_field,
            }))

    class Users(Document):
        users = ArrayField(DocumentField(User))

    Users.get_schema()

    role = 'db_role'
    with pytest.raises(SchemaGenerationException) as e:
        Users.get_schema(role=role)
    e = e.value

    assert list(e.steps) == [
        DocumentStep(Users, role=role),
        FieldStep(Users._backend, role=role),
        AttributeStep('properties', role=role),
        ItemStep('users', role=role),
        FieldStep(Users.users, role=role),
        AttributeStep('items', role=role),
        FieldStep(Users.users.items, role=role),
        DocumentStep(User, role=role),
        FieldStep(User._backend, role=role),
        AttributeStep('properties', role=role),
        ItemStep('friends', role=role),
        FieldStep(User.friends, role=role),
        AttributeStep('items', role=role),
        FieldStep(db_role_friends_field, role=role),
        AttributeStep('items', role=role),
        ItemStep(1, role=role)
    ]
    assert e.message == 'None is not resolvable'
    assert ("Steps: Users -> DocumentBackend.properties['users'] -> "
            "ArrayField.items -> DocumentField -> User -> "
            "DocumentBackend.properties['friends'] -> ArrayField.items -> "
            "ArrayField.items[1]") in str(e)
Exemplo n.º 7
0
class GnssAssistedDocument(CommonJobDocument):
    gnss_assisted_option = GnssOptionField()
    gnss_assisted_capture_mode = GnssCaptureModeField()
    gnss_assisted_nb_satellite = NumberField(multiple_of=1,
                                             minimum=0,
                                             maximum=255)
    gnss_assisted_antenna_selection = GnssAntennaSelectionField()
    gnss_assisted_constellations = ArrayField(GnssConstellationField())
    assisted_coordinate = DocumentField(AssistedCoordinateDocument)
Exemplo n.º 8
0
    class Task(Document):
        class Options(object):
            title = 'Task'
            description = 'A task.'
            definition_id = 'task'

        name = StringField(required=True, min_length=5)
        type = StringField(required=True, enum=['TYPE_1', 'TYPE_2'])
        resources = ArrayField(DocumentField(Resource))
        created_at = DateTimeField(name='created-at', required=True)
        author = DocumentField(User)
class GnssAutonomousDocument(CommonGnssJobDocument):
    gnss_autonomous_option = GnssOptionField()
    gnss_autonomous_capture_mode = GnssCaptureModeField()
    gnss_autonomous_nb_satellite = NumberField(
        multiple_of=1,
        minimum=0,
        maximum=255,
        description="Number of satellites to fetch during GNSS scan operation.",
    )
    gnss_autonomous_antenna_selection = GnssAntennaSelectionField()
    gnss_autonomous_constellations = ArrayField(GnssConstellationField())
class WifiJobDocument(CommonJobDocument):
    wifi_api = WifiApiField(required=True)
    wifi_channels = ArrayField(WiFiChanelField())
    wifi_types = ArrayField(WiFiTypeField())
    wifi_nbr_retrial = NumberField(
        minimum=0,
        multiple=1,
        description="Sets the number of Wi-Fi passive scan attempts to try per channels.",
    )
    wifi_max_result_per_scan = NumberField(
        minimum=0,
        multiple=1,
        description="Indicates the maximal number of Wi-Fi MAC addresses to fetch during passive scan operation.",
    )
    wifi_timeout = NumberField(
        minimum=0,
        multiple=1,
        description="Configures the maximal wait duration for a Wi-Fi preamble before considering a Wi-Fi channel is empty of signal. Expressed in ms.",
    )
    wifi_abort_on_timeout = BooleanField(
        description="Enable or disable the Wi-Fi abort on timeout. If set to True, the Wi-Fi scan will jump to next channel as soon as a preamble timeout is reached.",
        required=True,
    )
    wifi_mode = WifiModeField()
class JobsDocument(Document):
    infinite_loops = BooleanField(
        description="Configures the repetition of the jobs. If set to true, the job file will be repeated infinitely. If set to false, the field test will end at the end of the last job in this file."
    )
    scan_interval = NumberField(
        minimum=0,
        multiple_of=1,
        description="Number of seconds to wait between two consecutive list of jobs execution. Useful only if infinite_loops is true. Value in seconds. 0 means that there is no wait between list of jobs.",
        required=True,
    )
    jobs = ArrayField(
        OneOfField(
            fields=[
                DocumentField(WifiJobDocument),
                DocumentField(GnssAutonomousDocument),
                DocumentField(GnssAssistedDocument),
            ]
        ),
        description="Array of jobs description to be executed during field tests.",
    )
Exemplo n.º 12
0
class TypeStringList(Document):
    value = ArrayField(items=StringField(),
                       unique_items=True,
                       additional_items=False)
Exemplo n.º 13
0
def test_array_field():
    f = ArrayField(items=())
    with pytest.raises(SchemaGenerationException) as e:
        f.get_schema()
    assert list(e.value.steps) == [FieldStep(f), AttributeStep('items')]

    f = ArrayField(items=(
        Var({'role_x': StringField()}),
        Var({'role_x': IntField()}),
    ))
    role = 'role_y'
    with pytest.raises(SchemaGenerationException) as e:
        f.get_schema(role='role_y')
    assert list(e.value.steps) == [
        FieldStep(f, role=role),
        AttributeStep('items', role=role)
    ]

    f = ArrayField(items=(None, None))
    with pytest.raises(SchemaGenerationException) as e:
        f.get_schema()
    assert list(
        e.value.steps) == [FieldStep(f),
                           AttributeStep('items'),
                           ItemStep(0)]

    f = ArrayField(items=object())
    with pytest.raises(SchemaGenerationException) as e:
        f.get_schema()
    assert list(e.value.steps) == [FieldStep(f), AttributeStep('items')]

    f = ArrayField(additional_items=object())
    with pytest.raises(SchemaGenerationException) as e:
        f.get_schema()
    assert list(
        e.value.steps) == [FieldStep(f),
                           AttributeStep('additional_items')]

    f = ArrayField(items=FieldStub())
    with pytest.raises(SchemaGenerationException) as e:
        f.get_schema()
    e = e.value
    assert e.message == FieldStub.ERROR_MESSAGE
    assert list(e.steps) == [FieldStep(f), AttributeStep('items')]

    f = ArrayField(items=(FieldStub(), ))
    with pytest.raises(SchemaGenerationException) as e:
        f.get_schema()
    e = e.value
    assert e.message == FieldStub.ERROR_MESSAGE
    assert list(e.steps) == [FieldStep(f), AttributeStep('items'), ItemStep(0)]

    f = ArrayField(additional_items=FieldStub())
    with pytest.raises(SchemaGenerationException) as e:
        f.get_schema()
    e = e.value
    assert e.message == FieldStub.ERROR_MESSAGE
    assert list(e.steps) == [FieldStep(f), AttributeStep('additional_items')]
Exemplo n.º 14
0
 class Users(Document):
     users = ArrayField(DocumentField(User))
Exemplo n.º 15
0
class CheckOutput(Document):
    checks = ArrayField(items=DocumentField(CheckEntry, as_ref=True),
                        additional_items=False)
Exemplo n.º 16
0
class StringList(Document):
    value = ArrayField(items=StringField(), additional_items=False)
Exemplo n.º 17
0
class ErrorList(Document):
    value = ArrayField(items=DocumentField(Error, as_ref=True),
                       additional_items=False)
Exemplo n.º 18
0
def test_array_field():
    f = ArrayField(items=())
    with pytest.raises(SchemaGenerationException) as e:
        f.get_schema()
    assert list(e.value.steps) == [FieldStep(f), AttributeStep('items')]

    f = ArrayField(items=(
        Var({'role_x': StringField()}),
        Var({'role_x': IntField()}),
    ))
    role = 'role_y'
    with pytest.raises(SchemaGenerationException) as e:
        f.get_schema(role='role_y')
    assert list(e.value.steps) == [FieldStep(f, role=role), AttributeStep('items', role=role)]

    f = ArrayField(items=(None, None))
    with pytest.raises(SchemaGenerationException) as e:
        f.get_schema()
    assert list(e.value.steps) == [FieldStep(f), AttributeStep('items'), ItemStep(0)]

    f = ArrayField(items=object())
    with pytest.raises(SchemaGenerationException) as e:
        f.get_schema()
    assert list(e.value.steps) == [FieldStep(f), AttributeStep('items')]

    f = ArrayField(additional_items=object())
    with pytest.raises(SchemaGenerationException) as e:
        f.get_schema()
    assert list(e.value.steps) == [FieldStep(f), AttributeStep('additional_items')]

    f = ArrayField(items=FieldStub())
    with pytest.raises(SchemaGenerationException) as e:
        f.get_schema()
    e = e.value
    assert e.message == FieldStub.ERROR_MESSAGE
    assert list(e.steps) == [FieldStep(f), AttributeStep('items')]

    f = ArrayField(items=(FieldStub(),))
    with pytest.raises(SchemaGenerationException) as e:
        f.get_schema()
    e = e.value
    assert e.message == FieldStub.ERROR_MESSAGE
    assert list(e.steps) == [FieldStep(f), AttributeStep('items'), ItemStep(0)]

    f = ArrayField(additional_items=FieldStub())
    with pytest.raises(SchemaGenerationException) as e:
        f.get_schema()
    e = e.value
    assert e.message == FieldStub.ERROR_MESSAGE
    assert list(e.steps) == [FieldStep(f), AttributeStep('additional_items')]