Ejemplo n.º 1
0
def test_op_does_not_exist_query(scd_session):
    time_now = datetime.datetime.utcnow()
    end_time = time_now + datetime.timedelta(hours=1)
    resp = scd_session.post('/operation_references/query',
                            json={
                                'area_of_interest':
                                scd.make_vol4(time_now, end_time, 0, 5000,
                                              scd.make_circle(-56, 178, 300))
                            },
                            scope=SCOPE_SC)
    assert resp.status_code == 200, resp.content
    assert OP_ID not in [
        op['id'] for op in resp.json().get('operation_references', [])
    ]

    resp = scd_session.post('/operation_references/query',
                            json={
                                'area_of_interest':
                                scd.make_vol4(time_now, end_time, 0, 5000,
                                              scd.make_circle(-56, 178, 300))
                            },
                            scope=SCOPE_CI)
    assert resp.status_code == 403, resp.content

    resp = scd_session.post('/operation_references/query',
                            json={
                                'area_of_interest':
                                scd.make_vol4(time_now, end_time, 0, 5000,
                                              scd.make_circle(-56, 178, 300))
                            },
                            scope=SCOPE_CM)
    assert resp.status_code == 403, resp.content
Ejemplo n.º 2
0
def test_search_footprint(ids, scd_api, scd_session):
    lat = LAT0 - scd.latitude_degrees(FOOTPRINT_SPACING_M)
    print(lat)
    resp = scd_session.post('/subscriptions/query',
                            json={
                                "area_of_interest":
                                scd.make_vol4(None, None, 0, 3000,
                                              scd.make_circle(lat, LNG0, 50))
                            })
    assert resp.status_code == 200, resp.content
    result_ids = [x['id'] for x in resp.json()['subscriptions']]
    assert ids(SUB1_TYPE) in result_ids
    assert ids(SUB2_TYPE) not in result_ids
    assert ids(SUB3_TYPE) not in result_ids

    resp = scd_session.post('/subscriptions/query',
                            json={
                                "area_of_interest":
                                scd.make_vol4(None, None, 0, 3000,
                                              scd.make_circle(LAT0, LNG0, 50))
                            })
    assert resp.status_code == 200, resp.content
    result_ids = [x['id'] for x in resp.json()['subscriptions']]
    assert ids(SUB1_TYPE) not in result_ids
    assert ids(SUB2_TYPE) in result_ids
    assert ids(SUB3_TYPE) not in result_ids
def _make_op_request_differ_in_time(idx, time_gap):
  delta = 10
  time_start = datetime.datetime.utcnow() +  time_gap + datetime.timedelta(minutes=delta * idx)
  time_end = time_start + datetime.timedelta(minutes=delta - 1)

  vol4 = scd.make_vol4(time_start, time_end, 0, 120, scd.make_circle(-56, 178, 50))
  return _make_op_request_with_extents(vol4)
Ejemplo n.º 4
0
def test_create_op2sub(scd_session, scd_session2):
    if scd_session2 is None:
        return
    time_start = datetime.datetime.utcnow()
    time_end = time_start + datetime.timedelta(minutes=70)
    req = {
        "extents":
        scd.make_vol4(time_start, time_end, 0, 1000,
                      scd.make_circle(89.999, 0, 250)),
        "old_version":
        0,
        "uss_base_url":
        URL_SUB2,
        "notify_for_operations":
        True,
        "notify_for_constraints":
        False
    }
    resp = scd_session2.put('/subscriptions/{}'.format(SUB2_ID), json=req)
    assert resp.status_code == 200, resp.content

    # The Subscription response should mention Op1, but not include its OVN
    data = resp.json()
    ops = data['operations']
    assert len(ops) > 0
    op = [op for op in ops if op['id'] == OP1_ID][0]
    assert not op.get('ovn', '')

    assert data['subscription']['notification_index'] == 0

    resp = scd_session2.get('/subscriptions/{}'.format(SUB2_ID))
    assert resp.status_code == 200, resp.content
def _make_op_request_differ_in_2d(idx):
  time_start = datetime.datetime.utcnow() + datetime.timedelta(minutes=20)
  time_end = time_start + datetime.timedelta(minutes=60)
  lat = _calculate_lat(idx)

  vol4 = scd.make_vol4(time_start, time_end, 0, 120, scd.make_circle(lat, 178, 50))
  return _make_op_request_with_extents(vol4)
Ejemplo n.º 6
0
def test_get_op_by_search_latest_time_excluded(ids, scd_api, scd_session):
  latest_time = datetime.datetime.utcnow() + datetime.timedelta(minutes=1)
  resp = scd_session.post('/operational_intent_references/query', json={
    'area_of_interest': scd.make_vol4(None, latest_time, 0, 5000, scd.make_circle(-56, 178, 300))
  })
  assert resp.status_code == 200, resp.content
  assert ids(OP_TYPE) not in [x['id'] for x in resp.json()['operational_intent_references']]
Ejemplo n.º 7
0
def test_read_ops_from_uss2_v17(ids, scd_api, scd_session, scd_session2):
    if scd_session2 is None:
        return
    time_now = datetime.datetime.utcnow()
    end_time = time_now + datetime.timedelta(hours=1)
    resp = scd_session2.post('/operational_intent_references/query',
                             json={
                                 'area_of_interest':
                                 scd.make_vol4(
                                     time_now, end_time, 0, 5000,
                                     scd.make_circle(89.999, 180, 300))
                             })
    assert resp.status_code == 200, resp.content

    ops = {
        op['id']: op
        for op in resp.json().get('operational_intent_references', [])
    }
    assert ids(OP1_TYPE) in ops
    assert ids(OP2_TYPE) in ops

    ovn1 = ops[ids(OP1_TYPE)].get('ovn', '')
    ovn2 = ops[ids(OP2_TYPE)].get('ovn', '')
    assert ovn1 in scd.NO_OVN_PHRASES
    assert ovn2 not in scd.NO_OVN_PHRASES
Ejemplo n.º 8
0
def test_sub_does_not_exist_query(ids, scd_api, scd_session):
  if scd_session is None:
    return
  resp = scd_session.post('/subscriptions/query', json={
    'area_of_interest': scd.make_vol4(None, None, 0, 5000, scd.make_circle(12, -34, 300))
  })
  assert resp.status_code == 200, resp.content
  assert ids(SUB_TYPE) not in [sub['id'] for sub in resp.json().get('subscriptions', [])]
def _query_operation(idx, scd_session):
    lat = _calculate_lat(idx)
    return scd_session.post('/operation_references/query',
                            json={
                                'area_of_interest':
                                scd.make_vol4(None, None, 0, 5000,
                                              scd.make_circle(lat, 178, 12000))
                            },
                            scope=SCOPE_SC)
Ejemplo n.º 10
0
def test_get_deleted_op_by_search(scd_session):
    resp = scd_session.post('/operation_references/query',
                            json={
                                'area_of_interest':
                                scd.make_vol4(None, None, 0, 5000,
                                              scd.make_circle(-56, 178, 300))
                            })
    assert resp.status_code == 200, resp.content
    assert OP_ID not in [x['id'] for x in resp.json()['operation_references']]
def _make_op_request_differ_in_altitude(idx):
  time_start = datetime.datetime.utcnow() + datetime.timedelta(minutes=20)
  time_end = time_start + datetime.timedelta(minutes=60)
  delta = 20
  alt0 = delta * idx
  alt1 = alt0 + delta - 1

  vol4 = scd.make_vol4(time_start, time_end, alt0, alt1, scd.make_circle(-56, 178, 50))
  return _make_op_request_with_extents(vol4)
Ejemplo n.º 12
0
def test_get_op_by_search_earliest_time_included(scd_session):
    earliest_time = datetime.datetime.utcnow() + datetime.timedelta(minutes=59)
    resp = scd_session.post('/operation_references/query',
                            json={
                                'area_of_interest':
                                scd.make_vol4(earliest_time, None, 0, 5000,
                                              scd.make_circle(-56, 178, 300))
                            })
    assert resp.status_code == 200, resp.content
    assert OP_ID in [x['id'] for x in resp.json()['operation_references']]
Ejemplo n.º 13
0
def test_get_op_by_search(ids, scd_api, scd_session):
    resp = scd_session.post('/operational_intent_references/query',
                            json={
                                'area_of_interest':
                                scd.make_vol4(None, None, 0, 5000,
                                              scd.make_circle(-56, 178, 300))
                            })
    assert resp.status_code == 200, resp.content
    assert ids(OP_TYPE) in [
        x['id'] for x in resp.json().get('operational_intent_references', [])
    ], resp.json()
Ejemplo n.º 14
0
def test_get_deleted_constraint_by_search(ids, scd_api, scd_session):
    resp = scd_session.post('/constraint_references/query',
                            json={
                                'area_of_interest':
                                scd.make_vol4(None, None, 0, 5000,
                                              scd.make_circle(-56, 178, 300))
                            })
    assert resp.status_code == 200, resp.content
    assert ids(CONSTRAINT_TYPE) not in [
        x['id'] for x in resp.json()['constraint_references']
    ]
def test_get_deleted_ops_by_search_v15(ids, scd_api, scd_session):
    resp = scd_session.post('/operational_intent_references/query',
                            json={
                                'area_of_interest':
                                scd.make_vol4(None, None, 0, 5000,
                                              scd.make_circle(-56, 178, 12000))
                            })
    assert resp.status_code == 200, resp.content
    found_ids = [
        op['id'] for op in resp.json().get('operational_intent_reference', [])
    ]
    assert not _intersection(map(ids, OP_TYPES), found_ids)
Ejemplo n.º 16
0
def test_get_ops_by_search(scd_session):
    resp = scd_session.post('/operation_references/query',
                            json={
                                'area_of_interest':
                                scd.make_vol4(None, None, 0, 5000,
                                              scd.make_circle(-56, 178, 12000))
                            })
    assert resp.status_code == 200, resp.content
    found_ids = [
        op['id'] for op in resp.json().get('operation_references', [])
    ]
    assert len(_intersection(OP_IDS, found_ids)) == len(OP_IDS)
Ejemplo n.º 17
0
def test_get_constraint_by_search_latest_time_excluded(scd_session):
    latest_time = datetime.datetime.utcnow() - datetime.timedelta(minutes=1)
    resp = scd_session.post('/constraint_references/query',
                            json={
                                'area_of_interest':
                                scd.make_vol4(None, latest_time, 0, 5000,
                                              scd.make_circle(-56, 178, 300))
                            })
    assert resp.status_code == 200, resp.content
    assert CONSTRAINT_ID not in [
        x['id'] for x in resp.json()['constraint_references']
    ]
Ejemplo n.º 18
0
def test_get_deleted_sub_by_search(ids, scd_api, scd_session):
  if scd_session is None:
    return
  time_now = datetime.datetime.utcnow()
  resp = scd_session.post(
    '/subscriptions/query',
    json={
      "area_of_interest": scd.make_vol4(time_now, time_now, 0, 120,
                                        scd.make_circle(12.00001, -34.00001, 50))
    })
  assert resp.status_code == 200, resp.content
  assert ids(SUB_TYPE) not in [x['id'] for x in resp.json()['subscriptions']]
Ejemplo n.º 19
0
def _query_operation(idx, scd_session, scd_api):
    lat = _calculate_lat(idx)
    if scd_api == scd.API_0_3_5:
        return scd_session.post('/operation_references/query',
                                json={
                                    'area_of_interest':
                                    scd.make_vol4(
                                        None, None, 0, 5000,
                                        scd.make_circle(lat, 178, 12000))
                                },
                                scope=SCOPE_SC)
    elif scd_api == scd.API_0_3_17:
        return scd_session.post('/operational_intent_references/query',
                                json={
                                    'area_of_interest':
                                    scd.make_vol4(
                                        None, None, 0, 5000,
                                        scd.make_circle(lat, 178, 12000))
                                },
                                scope=SCOPE_SC)
    else:
        raise ValueError('Unsupported SCD API version: {}'.format(scd_api))
Ejemplo n.º 20
0
def test_subs_do_not_exist_query(scd_session):
    resp = scd_session.post('/subscriptions/query',
                            json={
                                'area_of_interest':
                                scd.make_vol4(
                                    None, None, 0, 5000,
                                    scd.make_circle(LAT0, LNG0,
                                                    FOOTPRINT_SPACING_M))
                            })
    assert resp.status_code == 200, resp.content
    result_ids = [x['id'] for x in resp.json()['subscriptions']]
    for sub_id in (SUB1_ID, SUB2_ID, SUB3_ID):
        assert sub_id not in result_ids
Ejemplo n.º 21
0
def test_get_constraint_by_search_earliest_time_included(
        ids, scd_api, scd_session):
    earliest_time = datetime.datetime.utcnow() + datetime.timedelta(minutes=59)
    resp = scd_session.post('/constraint_references/query',
                            json={
                                'area_of_interest':
                                scd.make_vol4(earliest_time, None, 0, 5000,
                                              scd.make_circle(-56, 178, 300))
                            })
    assert resp.status_code == 200, resp.content
    assert ids(CONSTRAINT_TYPE) in [
        x['id'] for x in resp.json()['constraint_references']
    ]
Ejemplo n.º 22
0
def test_search_find_all_subs(ids, scd_api, scd_session):
    resp = scd_session.post('/subscriptions/query',
                            json={
                                "area_of_interest":
                                scd.make_vol4(
                                    None, None, 0, 3000,
                                    scd.make_circle(LAT0, LNG0,
                                                    FOOTPRINT_SPACING_M))
                            })
    assert resp.status_code == 200, resp.content
    result_ids = [x['id'] for x in resp.json()['subscriptions']]
    for sub_id in (ids(SUB1_TYPE), ids(SUB2_TYPE), ids(SUB3_TYPE)):
        assert sub_id in result_ids
def _make_c1_request():
    time_start = datetime.datetime.utcnow()
    time_end = time_start + datetime.timedelta(minutes=60)
    return {
        'extents': [
            scd.make_vol4(time_start, time_end, 0, 120,
                          scd.make_circle(-12.00001, 33.99999, 50))
        ],
        'old_version':
        0,
        'uss_base_url':
        CONSTRAINT_BASE_URL_1,
    }
Ejemplo n.º 24
0
def test_get_ops_by_search_latest_time_included(scd_session):
    latest_time = datetime.datetime.utcnow() + datetime.timedelta(minutes=20)
    resp = scd_session.post('/operation_references/query',
                            json={
                                'area_of_interest':
                                scd.make_vol4(None, latest_time, 0, 5000,
                                              scd.make_circle(-56, 178, 12000))
                            })
    assert resp.status_code == 200, resp.content
    found_ids = [
        op['id'] for op in resp.json().get('operation_references', [])
    ]
    assert len(_intersection(OP_IDS, found_ids)) == len(OP_IDS)
Ejemplo n.º 25
0
def _make_c1_request():
    time_start = datetime.datetime.utcnow()
    time_end = time_start + datetime.timedelta(minutes=60)
    return {
        'extents': [
            scd.make_vol4(time_start, time_end, 0, 120,
                          scd.make_circle(-56, 178, 50))
        ],
        'old_version':
        0,
        'uss_base_url':
        BASE_URL,
    }
Ejemplo n.º 26
0
def _make_op_req():
  time_start = datetime.datetime.utcnow() + datetime.timedelta(minutes=20)
  time_end = time_start + datetime.timedelta(minutes=60)
  return {
    'extents': [scd.make_vol4(time_start, time_end, 0, 1000, scd.make_circle(-56, 178, 500))],
    'old_version': 0,
    'state': 'Accepted',
    'uss_base_url': BASE_URL,
    'new_subscription': {
      'uss_base_url': BASE_URL,
      'notify_for_constraints': False
    }
  }
def test_get_ops_by_search_latest_time_excluded_v15(ids, scd_api, scd_session):
    latest_time = datetime.datetime.utcnow() + datetime.timedelta(minutes=1)
    resp = scd_session.post('/operational_intent_references/query',
                            json={
                                'area_of_interest':
                                scd.make_vol4(None, latest_time, 0, 5000,
                                              scd.make_circle(-56, 178, 12000))
                            })
    assert resp.status_code == 200, resp.content
    found_ids = [
        op['id'] for op in resp.json().get('operational_intent_references', [])
    ]
    assert not _intersection(map(ids, OP_TYPES), found_ids)
Ejemplo n.º 28
0
def _make_sub1_req(scd_api):
  time_start = datetime.datetime.utcnow()
  time_end = time_start + datetime.timedelta(minutes=60)
  req = {
    "extents": scd.make_vol4(time_start, time_end, 0, 1000, scd.make_circle(12, -34, 300)),
    "uss_base_url": "https://example.com/foo",
    "notify_for_constraints": False
  }
  if scd_api == scd.API_0_3_5:
    req.update({"old_version": 0, "notify_for_operations": True})
  elif scd_api == scd.API_0_3_17:
    req.update({"notify_for_operational_intents": True})
  return req
Ejemplo n.º 29
0
def _make_sub_req(time_start, time_end, alt_start, alt_end, radius, scd_api):
  req = {
    "extents": scd.make_vol4(time_start, time_end, alt_start, alt_end, scd.make_circle(-56, 178, radius)),
    "old_version": 0,
    "uss_base_url": BASE_URL,

    "notify_for_constraints": False
  }
  if scd_api == scd.API_0_3_5:
    req["notify_for_operations"] = True
  elif scd_api == scd.API_0_3_17:
    req["notify_for_operational_intents"] = True
  return req
Ejemplo n.º 30
0
def test_get_constraint_by_search(scd_session):
    for scope in (SCOPE_SC, SCOPE_CI, SCOPE_CM):
        resp = scd_session.post('/constraint_references/query',
                                json={
                                    'area_of_interest':
                                    scd.make_vol4(
                                        None, None, 0, 5000,
                                        scd.make_circle(-56, 178, 300))
                                },
                                scope=scope)
        assert resp.status_code == 200, resp.content
        assert CONSTRAINT_ID in [
            x['id'] for x in resp.json().get('constraint_references', [])
        ]