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_database_returns_database_object(self):
database = Database('NSE')
self.assertIsInstance(database, Database)
self.assertEqual(database.database_code, 'NSE')
def test_database_calls_connection(self, mock):
database = Database('NSE')
database.data_fields()
expected = call('get', 'databases/NSE', params={})
self.assertEqual(mock.call_args, expected)
def setUp(self):
httpretty.enable()
httpretty.register_uri(httpretty.GET,
re.compile(
'https://www.quandl.com/api/v3/databases/*'),
adding_headers={
'Location': 'https://www.blah.com/download/db.zip'
},
body='{}', status=302)
httpretty.register_uri(httpretty.GET,
re.compile('https://www.blah.com/'), body='{}')
database = {'database': DatabaseFactory.build(database_code='NSE')}
self.database = Database(database['database']['database_code'], database['database'])
ApiConfig.api_key = 'api_token'
ApiConfig.api_version = '2015-04-09'
def test_databases_returns_database_objects(self):
results = Database.all()
self.assertEqual(len(results), 10)
for result in results:
self.assertIsInstance(result, Database)
def test_dataset_database_gives_instance_of_database(self):
database = self.dataset_instance.database()
self.assertIsInstance(database, Database)
def setUpClass(cls):
httpretty.enable()
database = {'database': DatabaseFactory.build(database_code='NSE')}
httpretty.register_uri(httpretty.GET,
re.compile(
'https://www.quandl.com/api/v3/databases/*'),
body=json.dumps(database))
cls.db_instance = Database(Database.get_code_from_meta(
database['database']), database['database'])
def test_databases_returns_database_objects(self):
results = Database.all()
self.assertEqual(len(results), 10)
for result in results:
self.assertIsInstance(result, Database)
def database(self):
return quandl.model.database.Database(self.database_code)