ArangoDB-Community / pyArango

Python Driver for ArangoDB with built-in validation
https://pyarango.readthedocs.io/en/latest/
Apache License 2.0
238 stars 90 forks source link

Connection, database actions and foxx can only be called when mount exists. Added tasks in Database #155

Closed dilipvamsi closed 5 years ago

dilipvamsi commented 5 years ago

Example.

>>> from pyArango import connection
>>> conn = connection.Connection(username, password)
>>> test_db = conn['test']
>>> test_db.foxx.services
[{'mount': '/_admin/aardvark',
  'name': 'aardvark',
  'version': '3.0.0',
  'provides': {},
  'development': False,
  'legacy': False},
 {'mount': '/_api/foxx',
  'name': 'foxx-manager',
  'version': '3.2.0',
  'provides': {},
  'development': False,
  'legacy': False}]
>>> test_db.foxx.mounts
{'/_admin/aardvark', '/_api/foxx'}
>>> test_db.foxx.service('/_admin/aardvark').get('/index.html')
<Response [200]>
>>> test_db.action.get('/_admin/aardvark/index.html')
<Response [200]>
>>> conn.action.get('/_db/test/_admin/aardvark/index.html')
<Response [200]>
>>> test_db.tasks.create('sample-task', 'console.log("sample-task", new Date());', period=10)
{'id': '1257206',
'name': 'sample-task',
'created': 1560173763.5678825,
'type': 'periodic',
'period': 10,
'offset': 0,
'command': '(function (params) { console.log("sample-task", new Date()); } )(params);',
'database': 'test_db_2'}
>>> test_db.tasks()
[{'id': '1257206',
  'name': 'sample-task',
  'created': 1560173763.5678825,
  'type': 'periodic',
  'period': 10,
  'offset': 1e-06,
  'command': '(function (params) { console.log("sample-task", new Date()); } )(params);',
  'database': 'test_db_2'}]
>>> test_db.tasks.fetch('1257206')
{'id': '1257206',
'name': 'sample-task',
'created': 1560173763.5678825,
'type': 'periodic',
'period': 10,
'offset': 1e-06,
'command': '(function (params) { console.log("sample-task", new Date()); } )(params);',
'database': 'test_db_2'}
>>> test_db.tasks.delete('1257206')
{'error': False, 'code': 200, 'result': '(non-representable type)'}
>>> test_db.tasks()
[]
codecov-io commented 5 years ago

Codecov Report

Merging #155 into dev will increase coverage by 0.47%. The diff coverage is 85.71%.

Impacted file tree graph

@@            Coverage Diff            @@
##              dev    #155      +/-   ##
=========================================
+ Coverage   77.92%   78.4%   +0.47%     
=========================================
  Files          14      16       +2     
  Lines        2854    2922      +68     
=========================================
+ Hits         2224    2291      +67     
- Misses        630     631       +1
Impacted Files Coverage Δ
pyArango/tests/tests.py 97.08% <100%> (+0.05%) :arrow_up:
pyArango/database.py 56.17% <100%> (+0.83%) :arrow_up:
pyArango/connection.py 77.84% <100%> (+0.25%) :arrow_up:
pyArango/action.py 71.42% <71.42%> (ø)
pyArango/foxx.py 92% <87.5%> (+24.55%) :arrow_up:
pyArango/tasks.py 90.32% <90.32%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update a0709fe...aa76674. Read the comment docs.

tariqdaouda commented 5 years ago

Thanks!

dilipvamsi commented 5 years ago

Hi @tariqdaouda , Can look into it and suggest the changes that are needed to made.