def test_metadata_single_acquisition(user_client, test_scheduler):
    entry_name = simulate_frequency_fft_acquisitions(user_client)
    tr = TaskResult.objects.get(schedule_entry__name=entry_name, task_id=1)
    acquisition = Acquisition.objects.get(task_result=tr)
    assert sigmf_validate(acquisition.metadata)
    check_metadata_fields(acquisition, entry_name,
                          SINGLE_FREQUENCY_FFT_ACQUISITION)
Exemplo n.º 2
0
def check_metadata_fields(metadata,
                          entry_name,
                          action_name,
                          task_id,
                          recording=None):
    assert sigmf_validate(metadata)
    # schema_validate(sigmf_metadata, schema)
    assert "ntia-scos:action" in metadata["global"]
    assert metadata["global"]["ntia-scos:action"]["name"] == action_name
    assert "ntia-scos:schedule" in metadata["global"]
    assert metadata["global"]["ntia-scos:schedule"]["name"] == entry_name
    assert "ntia-scos:task" in metadata["global"]
    assert metadata["global"]["ntia-scos:task"] == task_id
    if recording:
        assert "ntia-scos:recording" in metadata["global"]
        assert metadata["global"]["ntia-scos:recording"] == recording
    else:
        assert "ntia-scos:recording" not in metadata["global"]

    assert "ntia-core:measurement" in metadata["global"]
    assert metadata["global"]["ntia-core:measurement"]["time_start"]
    assert metadata["global"]["ntia-core:measurement"]["time_stop"]
    assert metadata["global"]["ntia-core:measurement"]["frequency_tuned_low"]
    assert metadata["global"]["ntia-core:measurement"]["frequency_tuned_high"]
    assert metadata["global"]["ntia-core:measurement"]["domain"]
    assert metadata["global"]["ntia-core:measurement"]["measurement_type"]
Exemplo n.º 3
0
def check_metadata_fields(acquisition,
                          entry_name,
                          schedule_entry,
                          is_multirecording=False):
    assert sigmf_validate(acquisition.metadata)
    assert "ntia-scos:action" in acquisition.metadata["global"]
    assert (acquisition.metadata["global"]["ntia-scos:action"]["name"] ==
            schedule_entry["action"])
    assert "ntia-scos:schedule" in acquisition.metadata["global"]
    assert acquisition.metadata["global"]["ntia-scos:schedule"][
        "name"] == entry_name
    assert "ntia-scos:task" in acquisition.metadata["global"]
    assert (acquisition.metadata["global"]["ntia-scos:task"] ==
            acquisition.task_result.task_id)
    if is_multirecording:
        assert "ntia-scos:recording" in acquisition.metadata["global"]
        assert (acquisition.metadata["global"]["ntia-scos:recording"] ==
                acquisition.recording_id)
    else:
        assert "ntia-scos:recording" not in acquisition.metadata["global"]

    assert "ntia-core:measurement" in acquisition.metadata["global"]
    assert acquisition.metadata["global"]["ntia-core:measurement"][
        "time_start"]
    assert acquisition.metadata["global"]["ntia-core:measurement"]["time_stop"]
    assert acquisition.metadata["global"]["ntia-core:measurement"][
        "frequency_tuned_low"]
    assert acquisition.metadata["global"]["ntia-core:measurement"][
        "frequency_tuned_high"]
    assert acquisition.metadata["global"]["ntia-core:measurement"]["domain"]
    assert acquisition.metadata["global"]["ntia-core:measurement"][
        "measurement_type"]
def test_metadata_multiple_acquisition(user_client, test_scheduler):
    entry_name = simulate_frequency_fft_acquisitions(user_client, n=2)
    task_results = TaskResult.objects.filter(schedule_entry__name=entry_name)
    for task_result in task_results:
        acquisition = Acquisition.objects.get(task_result=task_result)
        assert sigmf_validate(acquisition.metadata)
        check_metadata_fields(acquisition, entry_name,
                              MULTIPLE_FREQUENCY_FFT_ACQUISITIONS)
def test_detector(user_client, test_scheduler):
    entry_name = simulate_frequency_fft_acquisitions(user_client)
    tr = TaskResult.objects.get(schedule_entry__name=entry_name, task_id=1)
    acquisition = Acquisition.objects.get(task_result=tr)
    assert sigmf_validate(acquisition.metadata)
    # FIXME: update schema so that this passes
    # schema_validate(sigmf_metadata, schema)
    os.remove(acquisition.data.path)
def test_detector(user_client, rf):
    # Put an entry in the schedule that we can refer to
    rjson = post_schedule(user_client, TEST_SCHEDULE_ENTRY)
    entry_name = rjson['name']
    task_id = rjson['next_task_id']

    # use mock_acquire set up in conftest.py
    by_name['mock_acquire'](entry_name, task_id)
    acquistion = Acquisition.objects.get(task_id=task_id)
    sigmf_metadata = acquistion.sigmf_metadata
    assert sigmf_validate(sigmf_metadata)
def test_metadata(user_client, test_scheduler):
    entry_name = simulate_multirec_acquisition(user_client)
    tr = TaskResult.objects.get(schedule_entry__name=entry_name, task_id=1)
    acquisitions = Acquisition.objects.filter(task_result=tr)
    for acquisition in acquisitions:
        assert sigmf_validate(acquisition.metadata)