Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable bucketservice integration by default #535

Open
dankolbman opened this issue Sep 9, 2019 · 1 comment
Open

Disable bucketservice integration by default #535

dankolbman opened this issue Sep 9, 2019 · 1 comment
Labels
refactor Something needs to be done better

Comments

@dankolbman
Copy link
Contributor

Following kids-first/kf-api-bucketservice#35, we will need to start authenticating with the bucket service using auth0 service tokens. Due to kids-first/kf-api-study-creator#288, however, we will no longer be needing to create new buckets from the dataservice, so it will be easier to simply disable the bucket service integration entirely.

@dankolbman dankolbman added feature New functionality refactor Something needs to be done better labels Sep 9, 2019
@znatty22 znatty22 removed the feature New functionality label May 8, 2023
@znatty22
Copy link
Member

znatty22 commented May 8, 2023

Remove bucket creation code and testing

  • @event.listens_for(Study, 'after_insert', propagate=True)
    def make_bucket(mapper, connection, target):
    """
    Invokes the new bucket service to create a bucket in s3 for this study.
    Only creates a new bucket on insertion of a study.
    Will not attempt to remove the bucket on deletion to prevent any unwanted
    data loss.
    """
    url = current_app.config['BUCKET_SERVICE_URL']
    if url is not None:
    header = {}
    token = current_app.config['BUCKET_SERVICE_TOKEN']
    if token:
    header['Authorization'] = 'Bearer {}'.format(token)
    resp = requests.post(url+'/buckets',
    json={'study_id': target.kf_id},
    headers=header)
  • def test_bucket_service(self):
    """
    Test that a request is sent to create a new bucket
    """
    s = Study(external_id='phs002', short_code='KF-ST0')
    db.session.add(s)
    db.session.commit()
    assert self.bucket_service.post.call_count == 1
    headers = {'Authorization': 'Bearer test123'}
    self.bucket_service.post.assert_called_with('/buckets',
    json={'study_id': s.kf_id},
    headers=headers)
  • class WithBucketService():
    """ Mocks responses from the bucket service """
    def setUpBucketMock(self):
    mod = 'dataservice.api.study.models.requests'
    self.patch_bucket_service = patch(mod)
    self.bucket_service = self.patch_bucket_service.start()
    mock_resp_get = Mock()
    mock_resp_get.status_code = 200
    mock_resp_post = Mock()
    mock_resp_post.status_code = 201
    self.bucket_service.Session().get.side_effect = mock_resp_get
    self.bucket_service.Session().post.side_effect = mock_resp_post
    def tearDownBucketMock(self):
    self.bucket_service.stop()
  • class FlaskTestCase(unittest.TestCase, WithBucketService):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor Something needs to be done better
Projects
None yet
Development

No branches or pull requests

2 participants