Exemplo n.º 1
0
def public_source_group2(public_group2):
    obj = ObjFactory(groups=[public_group2])
    source = Source(obj_id=obj.id, group_id=public_group2.id)
    DBSession.add(source)
    DBSession.commit()
    yield obj
    ObjFactory.teardown(obj)
Exemplo n.º 2
0
def public_candidate_two_groups(public_filter, public_filter2, public_group,
                                public_group2):
    obj = ObjFactory(groups=[public_group, public_group2])
    DBSession.add(Candidate(obj=obj, filter=public_filter))
    DBSession.add(Candidate(obj=obj, filter=public_filter2))
    DBSession.commit()
    return obj
Exemplo n.º 3
0
def test_remote(driver):
    # TODO expand to cover the basics of all site functionality
    # (c.f. `test_pipeline_sequentially` from `cesium_web`)
    Source.query.delete()
    DBSession.commit()
    driver.get("/")
    assert 'localhost' in driver.current_url
    driver.wait_for_xpath('//div[contains(.,"Welcome to SkyPortal.")]')
Exemplo n.º 4
0
def public_source_two_groups(public_group, public_group2):
    obj = ObjFactory(groups=[public_group, public_group2])
    sources = []
    for group in [public_group, public_group2]:
        source = Source(obj_id=obj.id, group_id=group.id)
        sources.append(source)
        DBSession.add(source)
    DBSession.commit()
    yield obj
    ObjFactory.teardown(obj)
Exemplo n.º 5
0
def public_candidate(public_filter, user):
    obj = ObjFactory(groups=[public_filter.group])
    candidate = Candidate(
        obj=obj,
        filter=public_filter,
        passed_at=datetime.utcnow() - timedelta(seconds=np.random.randint(0, 100)),
        uploader_id=user.id,
    )
    DBSession.add(candidate)
    DBSession.commit()
    yield obj
    ObjFactory.teardown(obj)
Exemplo n.º 6
0
def public_candidate2(public_filter, user):
    obj = ObjFactory(groups=[public_filter.group])
    DBSession.add(
        Candidate(
            obj=obj,
            filter=public_filter,
            passed_at=datetime.utcnow() -
            timedelta(seconds=np.random.randint(0, 100)),
            uploader_id=user.id,
        ))
    DBSession.commit()
    return obj
Exemplo n.º 7
0
def public_candidate_two_groups(public_filter, public_filter2, public_group,
                                public_group2, user):
    obj = ObjFactory(groups=[public_group, public_group2])
    candidates = []
    for filter_ in [public_filter, public_filter2]:
        candidate = Candidate(
            obj=obj,
            filter=filter_,
            passed_at=datetime.utcnow() -
            timedelta(seconds=np.random.randint(0, 100)),
            uploader_id=user.id,
        )
        candidates.append(candidate)
        DBSession.add(candidate)
    DBSession.commit()
    yield obj
    ObjFactory.teardown(obj)
Exemplo n.º 8
0
def public_source_no_data(public_group):
    obj = Obj(
        id=str(uuid.uuid4()),
        ra=0.0,
        dec=0.0,
        redshift=0.0,
    )
    DBSession.add(obj)
    DBSession().add(ThumbnailFactory(obj_id=obj.id, type="new"))
    DBSession().add(ThumbnailFactory(obj_id=obj.id, type="ps1"))
    source = Source(obj_id=obj.id, group_id=public_group.id)
    DBSession.add(source)
    DBSession.commit()
    obj_id = obj.id
    yield obj
    # If the obj wasn't deleted by the test using it, clean up
    DBSession().expire(obj)
    if DBSession().query(Obj).filter(Obj.id == obj_id).first():
        DBSession().delete(obj)
        DBSession().commit()
Exemplo n.º 9
0
def public_candidate2(public_filter):
    obj = ObjFactory(groups=[public_filter.group])
    DBSession.add(Candidate(obj=obj, filter=public_filter))
    DBSession.commit()
    return obj
Exemplo n.º 10
0
def public_source_group2(public_group2):
    obj = ObjFactory(groups=[public_group2])
    DBSession.add(Source(obj_id=obj.id, group_id=public_group2.id))
    DBSession.commit()
    return obj
Exemplo n.º 11
0
def public_source_two_groups(public_group, public_group2):
    obj = ObjFactory(groups=[public_group, public_group2])
    for group in [public_group, public_group2]:
        DBSession.add(Source(obj_id=obj.id, group_id=group.id))
    DBSession.commit()
    return obj
Exemplo n.º 12
0
import astroplan

print("Loading test configuration from _test_config.yaml")
basedir = pathlib.Path(os.path.dirname(__file__))
cfg = load_config([(basedir / "../../test_config.yaml").absolute()])
set_server_url(f'http://localhost:{cfg["ports.app"]}')
print("Setting test database to:", cfg["database"])
models.init_db(**cfg["database"])

# Add a "test factory" User so that all factory-generated comments have a
# proper author, if it doesn't already exist (the user may already be in
# there if running the test server and running tests individually)
if not DBSession.query(User).filter(User.username == "test factory").scalar():
    DBSession.add(User(username="******"))
    DBSession.commit()


def pytest_runtest_setup(item):
    # Print timestamp when running each test
    print(datetime.now().strftime('[%H:%M:%S] '), end='')


# set up a hook to be able to check if a test has failed
@pytest.hookimpl(tryfirst=True, hookwrapper=True)
def pytest_runtest_makereport(item, call):
    # execute all other hooks to obtain the report object
    outcome = yield
    rep = outcome.get_result()

    # set a report attribute for each phase of a call, which can
Exemplo n.º 13
0
def public_candidate(public_filter):
    obj = ObjFactory()
    DBSession.add(Candidate(obj=obj, filter=public_filter))
    DBSession.commit()
    return obj
Exemplo n.º 14
0
def public_source(public_group):
    obj = ObjFactory()
    DBSession.add(Source(obj_id=obj.id, group_id=public_group.id))
    DBSession.commit()
    return obj