Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_sid_generation(self):
open_cga_client = OpenCGAClient(self.configuration, user='pepe', pwd='pepe')
expect(open_cga_client.session_id).to.equal('XOkCfKX09FV0YyPJCBvd')
open_cga_client = OpenCGAClient(self.configuration, session_id='XOkCfKX09FV0YyPJCBvd')
expect(open_cga_client.session_id).to.equal('XOkCfKX09FV0YyPJCBvd')
open_cga_client.projects.info('pt')
expect(httpretty.last_request()).to.have.property(
"headers").which.have.property('headers').which.should.equal(['Host: mock-opencga\r\n',
'Connection: keep-alive\r\n',
'Accept-Encoding: gzip\r\n',
'Accept: */*\r\n',
'User-Agent: python-requests/2.17.3\r\n',
'Authorization: Bearer XOkCfKX09FV0YyPJCBvd\r\n']
)
def test_pagination(self):
open_cga_client = OpenCGAClient(self.configuration, session_id='XOkCfKX09FV0YyPJCBvd')
r = open_cga_client.files.search(study='st')
expect(len(r.get())).equal_to(10000)
r = open_cga_client.files.search(study='st', limit=500)
expect(len(r.get())).equal_to(500)
for batch in open_cga_client.analysis_variant.query(5001, data={}):
expect(len(batch.get())).lower_than_or_equal_to(5001)
def test_sid_generation(self):
open_cga_client = OpenCGAClient(self.configuration, user='pepe', pwd='pepe')
expect(open_cga_client.session_id).to.equal('XOkCfKX09FV0YyPJCBvd')
open_cga_client = OpenCGAClient(self.configuration, session_id='XOkCfKX09FV0YyPJCBvd')
expect(open_cga_client.session_id).to.equal('XOkCfKX09FV0YyPJCBvd')
open_cga_client.projects.info('pt')
expect(httpretty.last_request()).to.have.property(
"headers").which.have.property('headers').which.should.equal(['Host: mock-opencga\r\n',
'Connection: keep-alive\r\n',
'Accept-Encoding: gzip\r\n',
'Accept: */*\r\n',
'User-Agent: python-requests/2.17.3\r\n',
'Authorization: Bearer XOkCfKX09FV0YyPJCBvd\r\n']
)
def test_extra_parameters(self):
open_cga_client = OpenCGAClient(self.configuration, session_id='XOkCfKX09FV0YyPJCBvd')
open_cga_client.projects.info('pt', extra='as_argument', **{'extra2': 'as_kwargs'})
expect(httpretty.last_request()).to.have.property(
"querystring").which.should.have.key('extra').which.should.equal(['as_argument'])
expect(httpretty.last_request()).to.have.property(
"querystring").which.should.have.key('extra2').which.should.equal(['as_kwargs'])
def create_session_file(configuration, opencga_dir):
fdw = open(os.path.join(opencga_dir, 'session_python.json'), 'w')
user = raw_input("User: ")
pwd = getpass.getpass()
o = OpenCGAClient(configuration=configuration, user=user, pwd=pwd)
session = {'userId': user, 'sessionId': o.session_id}
json.dump(session, fdw)
fdw.close()
sid = session['sessionId']
return sid