Skip to content

Commit 40bbbc9

Browse files
authored
Merge pull request #37 from joowani/develop
Add parameter replication_factor to method Database.create_collection
2 parents b724c6f + 328d8be commit 40bbbc9

File tree

8 files changed

+34
-14
lines changed

8 files changed

+34
-14
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ python:
44
- 2.7
55
- 3.4
66
- 3.5
7+
- 3.6
78
before_install:
89
- sh scripts/setup_arangodb.sh
910
install:

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
:target: https://badge.fury.io/py/python-arango
1515
:alt: Package Version
1616

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

@@ -45,7 +45,7 @@ Features
4545
Compatibility
4646
=============
4747

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

arango/database.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,8 @@ def create_collection(self,
237237
key_generator="traditional",
238238
shard_fields=None,
239239
shard_count=None,
240-
index_bucket_count=None):
240+
index_bucket_count=None,
241+
replication_factor=None):
241242
"""Create a new collection.
242243
243244
.. note::
@@ -280,6 +281,21 @@ def create_collection(self,
280281
parallel (e.g. 64 might be a sensible value for a collection with
281282
100,000,000 documents.
282283
:type index_bucket_count: int
284+
:param replication_factor: the number of copies of each shard on
285+
different servers in a cluster, whose allowed values are:
286+
287+
.. code-block:: none
288+
289+
1: only one copy is kept (no synchronous replication).
290+
291+
k: k-1 replicas are kept and any two copies are replicated
292+
across different DBServers synchronously, meaning every
293+
write to the master is copied to all slaves before the
294+
operation is reported successful.
295+
296+
Default: ``1``.
297+
298+
:type replication_factor: int
283299
:returns: the new collection object
284300
:rtype: arango.collections.Collection
285301
:raises arango.exceptions.CollectionCreateError: if the collection
@@ -308,6 +324,8 @@ def create_collection(self,
308324
data['shardKeys'] = shard_fields
309325
if index_bucket_count is not None:
310326
data['indexBuckets'] = index_bucket_count
327+
if replication_factor is not None:
328+
data['replicationFactor'] = replication_factor
311329

312330
res = self._conn.post('/_api/collection', data=data)
313331
if res.status_code not in HTTP_OK:

arango/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
VERSION = '3.5.0'
1+
VERSION = '3.6.0'

docs/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Features
2121
Compatibility
2222
=============
2323

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

scripts/setup_arangodb.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
44
cd $DIR
55

6-
VERSION=3.1.10
6+
VERSION=3.1.17
77
NAME=ArangoDB-$VERSION
88

99
if [ ! -d "$DIR/$NAME" ]; then

tests/test_cursor.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def test_read_cursor_init():
5656
assert cursor.warnings() == []
5757
assert cursor.count() == 4
5858
assert clean_keys(cursor.batch()) == [doc1, doc2]
59-
assert isinstance(cursor.statistics()['execution_time'], float)
59+
assert isinstance(cursor.statistics()['execution_time'], (int, float))
6060

6161

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

7878

7979
@pytest.mark.order3
@@ -90,7 +90,7 @@ def test_read_cursor_second():
9090
assert cursor.warnings() == []
9191
assert cursor.count() == 4
9292
assert clean_keys(cursor.batch()) == []
93-
assert isinstance(cursor.statistics()['execution_time'], float)
93+
assert isinstance(cursor.statistics()['execution_time'], (int, float))
9494

9595

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

112112

113113
@pytest.mark.order5
@@ -124,7 +124,7 @@ def test_read_cursor_finish():
124124
assert cursor.warnings() == []
125125
assert cursor.count() == 4
126126
assert clean_keys(cursor.batch()) == []
127-
assert isinstance(cursor.statistics()['execution_time'], float)
127+
assert isinstance(cursor.statistics()['execution_time'], (int, float))
128128
with pytest.raises(StopIteration):
129129
cursor.next()
130130
assert cursor.close(ignore_missing=True) is False
@@ -185,7 +185,7 @@ def test_write_cursor_init():
185185
assert cursor.warnings() == []
186186
assert cursor.count() == 2
187187
assert clean_keys(cursor.batch()) == [doc1]
188-
assert isinstance(cursor.statistics()['execution_time'], float)
188+
assert isinstance(cursor.statistics()['execution_time'], (int, float))
189189

190190

191191
@pytest.mark.order8
@@ -202,7 +202,7 @@ def test_write_cursor_first():
202202
assert cursor.warnings() == []
203203
assert cursor.count() == 2
204204
assert clean_keys(cursor.batch()) == []
205-
assert isinstance(cursor.statistics()['execution_time'], float)
205+
assert isinstance(cursor.statistics()['execution_time'], (int, float))
206206

207207

208208
@pytest.mark.order9
@@ -219,7 +219,7 @@ def test_write_cursor_second():
219219
assert cursor.warnings() == []
220220
assert cursor.count() == 2
221221
assert clean_keys(cursor.batch()) == []
222-
assert isinstance(cursor.statistics()['execution_time'], float)
222+
assert isinstance(cursor.statistics()['execution_time'], (int, float))
223223
with pytest.raises(StopIteration):
224224
cursor.next()
225225
assert cursor.close(ignore_missing=True) is False

tests/test_database.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ def test_create_collection():
8989
shard_count=2,
9090
shard_fields=["test_attr"],
9191
index_bucket_count=10,
92+
replication_factor=1
9293
)
9394
properties = col.properties()
9495
assert 'id' in properties

0 commit comments

Comments
 (0)