Esempio n. 1
0
def associate_sample(account_id, source_id, body, token_info):
    _validate_account_access(token_info, account_id)

    with Transaction() as t:
        sample_repo = SampleRepo(t)
        sample_repo.associate_sample(account_id, source_id, body['sample_id'])
        t.commit()
    response = flask.Response()
    response.status_code = 201
    response.headers['Location'] = '/api/accounts/%s/sources/%s/samples/%s' % \
                                   (account_id, source_id, body['sample_id'])
    return response
def create_dummy_kit(account_id=None, source_id=None):
    with Transaction() as t:
        _create_mock_kit(t, barcodes=[BARCODE],
                         mock_sample_ids=[MOCK_SAMPLE_ID])

        # if an account and source were provided, put some dummy
        # collection info into the sample and associate it to this source
        if account_id is not None and source_id is not None:

            sample_info, _ = create_dummy_sample_objects(True)
            sample_repo = SampleRepo(t)
            sample_repo.associate_sample(account_id, source_id, MOCK_SAMPLE_ID)
            sample_repo.update_info(account_id, source_id, sample_info)

        t.commit()