Skip to content

Commit

Permalink
Merge pull request #37 from joowani/develop
Browse files Browse the repository at this point in the history
Add parameter replication_factor to method Database.create_collection
  • Loading branch information
joowani authored Apr 11, 2017
2 parents b724c6f + 328d8be commit 40bbbc9
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 14 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ python:
- 2.7
- 3.4
- 3.5
- 3.6
before_install:
- sh scripts/setup_arangodb.sh
install:
Expand Down
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
:target: https://badge.fury.io/py/python-arango
:alt: Package Version

.. image:: https://img.shields.io/badge/python-2.7%2C%203.4%2C%203.5-blue.svg
.. image:: https://img.shields.io/badge/python-2.7%2C%203.4%2C%203.5%2C%203.6-blue.svg
:target: https://github.com/joowani/python-arango
:alt: Python Versions

Expand Down Expand Up @@ -45,7 +45,7 @@ Features
Compatibility
=============

- Python versions 2.7.x, 3.4.x and 3.5.x are supported
- Python versions 2.7.x, 3.4.x, 3.5.x and 3.6.x are supported
- Latest version of python-arango (3.x) supports ArangoDB 3.x only
- Older versions of python-arango support ArangoDB 1.x ~ 2.x only

Expand Down
20 changes: 19 additions & 1 deletion arango/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,8 @@ def create_collection(self,
key_generator="traditional",
shard_fields=None,
shard_count=None,
index_bucket_count=None):
index_bucket_count=None,
replication_factor=None):
"""Create a new collection.
.. note::
Expand Down Expand Up @@ -280,6 +281,21 @@ def create_collection(self,
parallel (e.g. 64 might be a sensible value for a collection with
100,000,000 documents.
:type index_bucket_count: int
:param replication_factor: the number of copies of each shard on
different servers in a cluster, whose allowed values are:
.. code-block:: none
1: only one copy is kept (no synchronous replication).
k: k-1 replicas are kept and any two copies are replicated
across different DBServers synchronously, meaning every
write to the master is copied to all slaves before the
operation is reported successful.
Default: ``1``.
:type replication_factor: int
:returns: the new collection object
:rtype: arango.collections.Collection
:raises arango.exceptions.CollectionCreateError: if the collection
Expand Down Expand Up @@ -308,6 +324,8 @@ def create_collection(self,
data['shardKeys'] = shard_fields
if index_bucket_count is not None:
data['indexBuckets'] = index_bucket_count
if replication_factor is not None:
data['replicationFactor'] = replication_factor

res = self._conn.post('/_api/collection', data=data)
if res.status_code not in HTTP_OK:
Expand Down
2 changes: 1 addition & 1 deletion arango/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION = '3.5.0'
VERSION = '3.6.0'
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Features
Compatibility
=============

- Python versions 2.7.x, 3.4.x and 3.5.x are supported
- Python versions 2.7.x, 3.4.x, 3.5.x and 3.6.x are supported
- Latest version of python-arango (3.x) supports ArangoDB 3.x only
- Older versions of python-arango support ArangoDB 1.x ~ 2.x only

Expand Down
2 changes: 1 addition & 1 deletion scripts/setup_arangodb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DIR

VERSION=3.1.10
VERSION=3.1.17
NAME=ArangoDB-$VERSION

if [ ! -d "$DIR/$NAME" ]; then
Expand Down
16 changes: 8 additions & 8 deletions tests/test_cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def test_read_cursor_init():
assert cursor.warnings() == []
assert cursor.count() == 4
assert clean_keys(cursor.batch()) == [doc1, doc2]
assert isinstance(cursor.statistics()['execution_time'], float)
assert isinstance(cursor.statistics()['execution_time'], (int, float))


@pytest.mark.order2
Expand All @@ -73,7 +73,7 @@ def test_read_cursor_first():
assert cursor.warnings() == []
assert cursor.count() == 4
assert clean_keys(cursor.batch()) == [doc2]
assert isinstance(cursor.statistics()['execution_time'], float)
assert isinstance(cursor.statistics()['execution_time'], (int, float))


@pytest.mark.order3
Expand All @@ -90,7 +90,7 @@ def test_read_cursor_second():
assert cursor.warnings() == []
assert cursor.count() == 4
assert clean_keys(cursor.batch()) == []
assert isinstance(cursor.statistics()['execution_time'], float)
assert isinstance(cursor.statistics()['execution_time'], (int, float))


@pytest.mark.order4
Expand All @@ -107,7 +107,7 @@ def test_read_cursor_third():
assert cursor.warnings() == []
assert cursor.count() == 4
assert clean_keys(cursor.batch()) == [doc3]
assert isinstance(cursor.statistics()['execution_time'], float)
assert isinstance(cursor.statistics()['execution_time'], (int, float))


@pytest.mark.order5
Expand All @@ -124,7 +124,7 @@ def test_read_cursor_finish():
assert cursor.warnings() == []
assert cursor.count() == 4
assert clean_keys(cursor.batch()) == []
assert isinstance(cursor.statistics()['execution_time'], float)
assert isinstance(cursor.statistics()['execution_time'], (int, float))
with pytest.raises(StopIteration):
cursor.next()
assert cursor.close(ignore_missing=True) is False
Expand Down Expand Up @@ -185,7 +185,7 @@ def test_write_cursor_init():
assert cursor.warnings() == []
assert cursor.count() == 2
assert clean_keys(cursor.batch()) == [doc1]
assert isinstance(cursor.statistics()['execution_time'], float)
assert isinstance(cursor.statistics()['execution_time'], (int, float))


@pytest.mark.order8
Expand All @@ -202,7 +202,7 @@ def test_write_cursor_first():
assert cursor.warnings() == []
assert cursor.count() == 2
assert clean_keys(cursor.batch()) == []
assert isinstance(cursor.statistics()['execution_time'], float)
assert isinstance(cursor.statistics()['execution_time'], (int, float))


@pytest.mark.order9
Expand All @@ -219,7 +219,7 @@ def test_write_cursor_second():
assert cursor.warnings() == []
assert cursor.count() == 2
assert clean_keys(cursor.batch()) == []
assert isinstance(cursor.statistics()['execution_time'], float)
assert isinstance(cursor.statistics()['execution_time'], (int, float))
with pytest.raises(StopIteration):
cursor.next()
assert cursor.close(ignore_missing=True) is False
Expand Down
1 change: 1 addition & 0 deletions tests/test_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def test_create_collection():
shard_count=2,
shard_fields=["test_attr"],
index_bucket_count=10,
replication_factor=1
)
properties = col.properties()
assert 'id' in properties
Expand Down

0 comments on commit 40bbbc9

Please sign in to comment.