예제 #1
0
파일: test_scp.py 프로젝트: qurit/raiven
def test_store_valid_user(db, stub_broker, stub_worker):
    # Ensure no DicomNodes in test data
    db.query(DicomNode).delete()
    db.commit()

    # Send dicom to user
    association = get_association_to_ae(config.USER_AE_PREFIX +
                                        utils.get_test_user(db).username)
    perform_store(association)
    sleep(
        1
    )  # Ensure detached SCP server has enough time to send job to worker before .join
    join(stub_broker, stub_worker)

    user = utils.get_test_user(db)
    assert db.query(DicomNode).filter_by(user_id=user.id).first()
예제 #2
0
def example_container():
    assert os.path.exists(
        mock_path := os.path.join(os.path.dirname(__file__), 'mock_data'))
    assert os.path.exists(
        file_path := os.path.join(mock_path, 'simple_container.zip'))
    assert os.path.isfile(file_path)

    with open(file_path, 'rb') as fp:
        data = fp.read()

    with testing_session() as db:
        container = create_container(auto_build=False,
                                     file=data,
                                     name='Test Container',
                                     filename='simple_container.zip',
                                     description='A simple container',
                                     is_input_container=False,
                                     is_output_container=False,
                                     is_shared=False,
                                     user=utils.get_test_user(db),
                                     db=db)

        yield container

        delete_container(container_id=container.id, db=db)
예제 #3
0
def insert_pipeline(db, name, **kwargs) -> Pipeline:
    user = utils.get_test_user(db)
    pipeline = Pipeline(user_id=user.id, name=name, **kwargs)
    pipeline.save(db)
    db.commit()

    assert pipeline.id
    assert pipeline.user_id

    return pipeline
 def help_test_upload(self, endpoint, payload):
     """Ensure a raw tool result can be uploaded."""
     auth_headers, _ = get_test_user(self.client)
     with self.client:
         response = self.client.post(
             endpoint,
             headers=auth_headers,
             data=json.dumps(payload),
             content_type='application/json',
         )
         data = json.loads(response.data.decode())
         self.assertEqual(response.status_code, 201)
         self.assertIn('success', data['status'])
예제 #5
0
def malformed_container():
    with testing_session() as db:
        container = create_container(auto_build=False,
                                     file=b'Pythons are cool',
                                     name='Test Container',
                                     filename='Dockerfile',
                                     description='A simple container',
                                     is_input_container=False,
                                     is_output_container=False,
                                     is_shared=False,
                                     user=utils.get_test_user(db),
                                     db=db)

        yield container

        delete_container(container_id=container.id, db=db)
예제 #6
0
파일: test_dicom.py 프로젝트: qurit/raiven
def test_get_user_dicom_nodes(db, authorization_header):
    # Delete existing DICOM nodes in db
    db.query(DicomNode).delete()
    db.commit()

    current_user = utils.get_test_user(db)
    other_user = utils.create_local_user("other", "other", "other")

    # Create DICOM
    global_node = save_node_for_user_id(None, db)
    user_node = save_node_for_user_id(current_user.id, db)
    db.commit()

    response = client.get(f'/dicom/nodes', headers=authorization_header)
    data = response.json()

    assert response.status_code == 200
    assert len(data) == 2
    for node in data:
        assert node['user_id'] in [global_node.user_id, user_node.user_id]
예제 #7
0
def create_and_test_container(db, file_path, **kwargs):
    with open(file_path, 'rb') as fp:
        data = fp.read()

    container = create_container(
        auto_build=kwargs.get('auto_build', False),
        file=data,
        name=kwargs.get('name', 'test_container_create_zip'),
        filename=kwargs.get('filename', 'simple_container.zip'),
        description=kwargs.get('description', 'A simple container'),
        is_input_container=kwargs.get('is_input_container', False),
        is_output_container=kwargs.get('is_output_container', False),
        is_shared=kwargs.get('is_shared', False),
        user=utils.get_test_user(db),
        db=db)

    assert type(container) is not list
    assert type(container) is Container
    assert pathlib.Path(container.get_abs_path()).exists()
    assert not pathlib.Path(container.get_path()).is_absolute()
    assert container.dockerfile_path == pathlib.Path(
        container.dockerfile_path).as_posix()
    return container
예제 #8
0
파일: test_auth.py 프로젝트: qurit/raiven
def test_expired_token(custom_serializer, db):
    test_user = utils.get_test_user(db)
    token = test_user.generate_token()

    sleep(1)
    assert not custom_serializer.verify_token(token)