Skip to content

Commit b2239da

Browse files
author
Joohwan Oh
committed
Update script for travis, pep8 fixes
1 parent 48e8d02 commit b2239da

15 files changed

+104
-74
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ language: python
22
python:
33
- "2.7"
44
before_install:
5-
- "sh setup_arangodb_2.3.sh"
5+
- "sh setup_arangodb_2.4.sh"
66
install:
77
- "pip install ."
88
script: nosetests

arango/batch.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import re
21
import json
3-
import logging
42
import inspect
53
from urllib import urlencode
64

@@ -20,15 +18,14 @@ def execute_batch(self, requests):
2018
for content_id, request in enumerate(requests, start=1):
2119
try:
2220
func, args, kwargs = request
23-
argspec = inspect.getargspec(func)[0]
24-
except TypeError, ValueError:
21+
except (TypeError, ValueError):
2522
raise BatchInvalidError(
2623
"pos {}: malformed request".format(content_id)
2724
)
2825
if "_batch" not in inspect.getargspec(func)[0]:
2926
raise BatchInvalidError(
3027
"pos {}: ArangoDB method '{}' does not support "
31-
"batch execution".format(content_id , func.__name__)
28+
"batch execution".format(content_id, func.__name__)
3229
)
3330
kwargs["_batch"] = True
3431
res = func(*args, **kwargs)
@@ -40,7 +37,7 @@ def execute_batch(self, requests):
4037
res = self._api.post(
4138
"/_api/batch",
4239
headers={
43-
"Content-Type": "multipart/form-data; boundary=XXXsubpartXXX"
40+
"Content-Type": "multipart/form-data; boundary=XXXsubpartXXX"
4441
},
4542
data=data,
4643
)

arango/clients/base.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
from abc import ABCMeta, abstractmethod
44

5-
from arango.response import ArangoResponse
6-
75

86
class BaseArangoClient(object):
97
"""Base ArangoDB HTTP client."""

arango/collection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import json
44

5-
from arango.utils import camelify, uncamelify, filter_keys
5+
from arango.utils import camelify, uncamelify
66
from arango.exceptions import *
77
from arango.cursor import CursorFactory
88

arango/database.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ def execute_query(self, query, count=False, batch_size=None, ttl=None,
160160
:type batch_size: int
161161
:param ttl: time-to-live for the cursor (in seconds)
162162
:type ttl: int
163-
:param bind_vars: key/value list of bind parameters
164-
:type bind_vars: list
163+
:param bind_vars: key-value pairs of bind parameters
164+
:type bind_vars: dict
165165
:param full_count: whether or not to include count before last LIMIT
166166
:param max_plans: maximum number of plans the optimizer generates
167167
:type max_plans: None or int

arango/method.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11

2+
23
# TODO Future implementation to replace the hacky _batch arguments
34
class ArangoRequest(object):
45

@@ -16,10 +17,10 @@ def javascript(self, *args, **kwargs):
1617

1718
def __call__(self, *args, **kwargs):
1819
request = self.request_info(*args, **kwargs)
19-
method = getattr(self._api, request["method"])
20+
http_method = getattr(self._api, request["method"])
2021
method_kwargs = {}
2122
for component in ["path", "params", "data", "headers"]:
2223
if component in request:
2324
method_kwargs[component] = request[component]
24-
endpoint = request["endpoint"]
25-
return handle_response(http_method(**method_kwargs))
25+
method_kwargs["endpoint"] = request["endpoint"]
26+
return self.handle_response(http_method(**method_kwargs))

arango/tests/test_aql_functions.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@
55
from arango import Arango
66
from arango.exceptions import *
77
from arango.tests.utils import (
8-
get_next_col_name,
98
get_next_db_name
109
)
1110

12-
class AQLFunctionManagementTest(unittest.TestCase):
1311

12+
class AQLFunctionManagementTest(unittest.TestCase):
1413

1514
def setUp(self):
1615
self.arango = Arango()

arango/tests/test_batch.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
get_next_graph_name,
99
)
1010

11+
1112
class BatchRequestTest(unittest.TestCase):
1213

1314
def setUp(self):
@@ -28,8 +29,8 @@ def setUp(self):
2829
self.graph = self.db.add_graph(
2930
name=self.graph_name,
3031
edge_definitions=[{
31-
"collection" : self.edge_col_name,
32-
"from" : [self.vertex_col_name],
32+
"collection": self.edge_col_name,
33+
"from": [self.vertex_col_name],
3334
"to": [self.vertex_col_name]
3435
}],
3536
)

arango/tests/test_document.py

Lines changed: 14 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ def setUp(self):
1717
self.arango = Arango()
1818
self.db_name = get_next_db_name(self.arango)
1919
self.db = self.arango.add_database(self.db_name)
20-
self.col_name = get_next_col_name(self.arango)
21-
self.col = self.arango.add_collection(self.col_name)
20+
self.col_name = get_next_col_name(self.db)
21+
self.col = self.db.add_collection(self.col_name)
2222
self.col.add_geo_index(["coord"])
2323
self.col.add_skiplist_index(["value"])
2424
self.col.add_fulltext_index(["text"])
@@ -199,8 +199,8 @@ def test_get_first_example(self):
199199
self.assertIn(
200200
strip_system_keys(self.col.get_first_example({"value": 1})),
201201
[
202-
{"name": "test_doc_01", "value" :1},
203-
{"name": "test_doc_02", "value" :1}
202+
{"name": "test_doc_01", "value": 1},
203+
{"name": "test_doc_02", "value": 1}
204204
]
205205
)
206206

@@ -213,7 +213,7 @@ def test_get_by_example(self):
213213
self.assertEqual(
214214
sorted(strip_system_keys(self.col.get_by_example({"value": 1}))),
215215
sorted([
216-
{"name": "test_doc_01", "value" :1},
216+
{"name": "test_doc_01", "value": 1},
217217
{"name": "test_doc_02", "value": 1},
218218
])
219219
)
@@ -296,10 +296,10 @@ def test_range(self):
296296

297297
def test_near(self):
298298
self.col.bulk_import([
299-
{"name": "test_doc_01", "coord": [1,1]},
300-
{"name": "test_doc_02", "coord": [1,4]},
301-
{"name": "test_doc_03", "coord": [4,1]},
302-
{"name": "test_doc_03", "coord": [4,4]},
299+
{"name": "test_doc_01", "coord": [1, 1]},
300+
{"name": "test_doc_02", "coord": [1, 4]},
301+
{"name": "test_doc_03", "coord": [4, 1]},
302+
{"name": "test_doc_03", "coord": [4, 4]},
303303
])
304304
self.assertEqual(
305305
strip_system_keys(
@@ -310,39 +310,16 @@ def test_near(self):
310310
)
311311
),
312312
[
313-
{"name": "test_doc_01", "coord": [1,1]}
313+
{"name": "test_doc_01", "coord": [1, 1]}
314314
]
315315
)
316316

317-
# TODO enable when the endpoint is fixed
318-
#def test_within(self):
319-
#self.col.bulk_import([
320-
#{"name": "test_doc_01", "coord": [1,1]},
321-
#{"name": "test_doc_02", "coord": [1,4]},
322-
#{"name": "test_doc_03", "coord": [4,1]},
323-
#{"name": "test_doc_03", "coord": [4,4]},
324-
#])
325-
#self.assertEqual(
326-
#strip_system_keys(
327-
#self.col.within(
328-
#latitude=0,
329-
#longitude=0,
330-
#radius=3.5,
331-
#)
332-
#),
333-
#[
334-
#{"name": "test_doc_01", "coord": [1,1]},
335-
#{"name": "test_doc_02", "coord": [1,4]},
336-
#{"name": "test_doc_03", "coord": [4,1]},
337-
#]
338-
#)
339-
340317
def test_fulltext(self):
341318
self.col.bulk_import([
342-
{"name": "test_doc_01", "text": "Hello World!"},
343-
{"name": "test_doc_02", "text": "foo"},
344-
{"name": "test_doc_03", "text": "bar"},
345-
{"name": "test_doc_03", "text": "baz"},
319+
{"name": "test_doc_01", "text": "Hello World!"},
320+
{"name": "test_doc_02", "text": "foo"},
321+
{"name": "test_doc_03", "text": "bar"},
322+
{"name": "test_doc_03", "text": "baz"},
346323
])
347324
self.assertEqual(
348325
strip_system_keys(self.col.fulltext("text", "foo,|bar")),

arango/tests/test_index.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ def test_add_geo_index_with_one_attr(self):
9797
ignore_null=False
9898
)
9999
self.assertEquals(
100-
sorted(self.col.indexes.values()),
101-
sorted([
100+
sorted(self.col.indexes.values()),
101+
sorted([
102102
{
103103
"type": "primary",
104104
"fields": ["_key"],
@@ -123,8 +123,8 @@ def test_add_geo_index_with_two_attrs(self):
123123
ignore_null=False
124124
)
125125
self.assertEquals(
126-
sorted(self.col.indexes.values()),
127-
sorted([
126+
sorted(self.col.indexes.values()),
127+
sorted([
128128
{
129129
"type": "primary",
130130
"fields": ["_key"],
@@ -158,8 +158,8 @@ def test_add_fulltext_index(self):
158158
min_length=10,
159159
)
160160
self.assertEquals(
161-
sorted(self.col.indexes.values()),
162-
sorted([
161+
sorted(self.col.indexes.values()),
162+
sorted([
163163
{
164164
"type": "primary",
165165
"fields": ["_key"],

arango/tests/test_query.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
get_next_db_name
1010
)
1111

12+
1213
class ArangoDBQueryTest(unittest.TestCase):
1314

1415
def setUp(self):

arango/tests/test_transaction.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,22 @@
55
from arango.tests.utils import (
66
get_next_db_name,
77
get_next_col_name,
8-
get_next_graph_name,
98
)
109

10+
1111
class BatchRequestTest(unittest.TestCase):
1212

1313
def setUp(self):
1414
self.arango = Arango()
15-
self.col_name01 = get_next_col_name(self.arango)
16-
self.col01 = self.arango.add_collection(self.col_name01)
17-
self.col_name02 = get_next_col_name(self.arango)
18-
self.col02 = self.arango.add_collection(self.col_name02)
15+
self.db_name = get_next_db_name(self.arango)
16+
self.db = self.arango.add_database(self.db_name)
17+
self.col_name01 = get_next_col_name(self.db)
18+
self.col01 = self.db.add_collection(self.col_name01)
19+
self.col_name02 = get_next_col_name(self.db)
20+
self.col02 = self.db.add_collection(self.col_name02)
1921

2022
def tearDown(self):
21-
self.arango.remove_collection(self.col_name01)
22-
self.arango.remove_collection(self.col_name02)
23+
self.arango.remove_database(self.db_name)
2324

2425
def test_execute_transaction(self):
2526
action = """
@@ -31,7 +32,7 @@ def test_execute_transaction(self):
3132
}
3233
""" % (self.col_name01, self.col_name02)
3334

34-
res = self.arango.execute_transaction(
35+
res = self.db.execute_transaction(
3536
action=action,
3637
read_collections=[self.col_name01, self.col_name02],
3738
write_collections=[self.col_name01, self.col_name02],

arango/tests/test_traversal.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
get_next_db_name
1010
)
1111

12+
1213
# TODO add more tests
1314
class EdgeManagementTest(unittest.TestCase):
1415

arango/tests/test_vertex.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
import unittest
44

55
from arango import Arango
6-
from arango.exceptions import *
76
from arango.tests.utils import (
87
get_next_graph_name,
98
get_next_col_name,
109
get_next_db_name
1110
)
1211

12+
1313
class VertexManagementTest(unittest.TestCase):
1414

1515
def setUp(self):
@@ -31,8 +31,8 @@ def setUp(self):
3131
self.graph = self.db.add_graph(
3232
name=self.graph_name,
3333
edge_definitions=[{
34-
"collection" : self.edge_col_name,
35-
"from" : [self.vertex_col_name],
34+
"collection": self.edge_col_name,
35+
"from": [self.vertex_col_name],
3636
"to": [self.vertex_col_name]
3737
}],
3838
)
@@ -109,6 +109,5 @@ def test_remove_vertex(self):
109109
self.assertEqual(len(self.vertex_col), 0)
110110

111111

112-
113112
if __name__ == "__main__":
114113
unittest.main()

setup_arangodb_2.4.sh

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/bin/bash
2+
3+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
4+
cd $DIR
5+
6+
VERSION=2.4.0
7+
NAME=ArangoDB-$VERSION
8+
9+
if [ ! -d "$DIR/$NAME" ]; then
10+
# download ArangoDB
11+
echo "wget http://www.arangodb.org/repositories/travisCI/$NAME.tar.gz"
12+
wget http://www.arangodb.org/repositories/travisCI/$NAME.tar.gz
13+
echo "tar zxf $NAME.tar.gz"
14+
tar zvxf $NAME.tar.gz
15+
fi
16+
17+
ARCH=$(arch)
18+
PID=$(echo $PPID)
19+
TMP_DIR="/tmp/arangodb.$PID"
20+
PID_FILE="/tmp/arangodb.$PID.pid"
21+
ARANGODB_DIR="$DIR/$NAME"
22+
ARANGOD="${ARANGODB_DIR}/bin/arangod_x86_64"
23+
24+
# create database directory
25+
mkdir ${TMP_DIR}
26+
27+
echo "Starting ArangoDB '${ARANGOD}'"
28+
29+
${ARANGOD} \
30+
--database.directory ${TMP_DIR} \
31+
--configuration none \
32+
--server.endpoint tcp://127.0.0.1:8529 \
33+
--javascript.app-path ${ARANGODB_DIR}/js/apps \
34+
--javascript.startup-directory ${ARANGODB_DIR}/js \
35+
--database.maximal-journal-size 1048576 \
36+
--server.disable-authentication true &
37+
38+
sleep 2
39+
40+
echo "Check for arangod process"
41+
process=$(ps auxww | grep "bin/arangod" | grep -v grep)
42+
43+
if [ "x$process" == "x" ]; then
44+
echo "no 'arangod' process found"
45+
echo "ARCH = $ARCH"
46+
exit 1
47+
fi
48+
49+
echo "Waiting until ArangoDB is ready on port 8529"
50+
while [[ -z `curl -s 'http://127.0.0.1:8529/_api/version' ` ]] ; do
51+
echo -n "."
52+
sleep 2s
53+
done
54+
55+
echo "ArangoDB is up"

0 commit comments

Comments
 (0)