Skip to content

Commit

Permalink
Tests passing after all PRs
Browse files Browse the repository at this point in the history
  • Loading branch information
heynemann committed Feb 19, 2018
1 parent 83c4322 commit 314685e
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 18 deletions.
5 changes: 0 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,21 @@ language: python

python:
- "2.7"
- "3.3"
- "3.4"
- "3.5"
- "3.6"
- "pypy"

matrix:
allow_failures:
- python: "3.3"
- python: "pypy"

install:
- pushd .

# installing mongodb
- sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5
- echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list
- sudo apt-get update
- sudo apt-get install -y mongodb-org

- make setup

script:
Expand Down
10 changes: 6 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
test:
test: mongo-test unit

unit:
@coverage run --branch `which nosetests` -vv --rednose -s tests/
@echo
@coverage report -m --fail-under=80
Expand All @@ -7,7 +9,7 @@ test:
doctest:
@cd docs && $(MAKE) doctest

ci_test: mongo_test test
ci_test: mongo-test test

tox:
@PATH=$$PATH:~/.pythonbrew/pythons/Python-2.6.*/bin/:~/.pythonbrew/pythons/Python-2.7.*/bin/:~/.pythonbrew/pythons/Python-3.0.*/bin/:~/.pythonbrew/pythons/Python-3.1.*/bin/:~/.pythonbrew/pythons/Python-3.2.3/bin/:~/.pythonbrew/pythons/Python-3.3.0/bin/ tox
Expand Down Expand Up @@ -36,13 +38,13 @@ setup:
@pip install -e .\[tests\]
@-pip install ujson

kill_mongo_test:
kill-mongo-test:
@ps aux | awk '(/mongod.+test/ && $$0 !~ /awk/){ system("kill -9 "$$2) }'
@rm -rf /tmp/motorengine_test/mongodata
@rm -rf /tmp/motorengine_test_2/mongodata
@rm -rf /tmp/motorengine_test_3/mongodata

mongo_test: kill_mongo_test
mongo-test: kill-mongo-test
@rm -rf /tmp/motorengine_test/mongotestdata && mkdir -p /tmp/motorengine_test/mongotestdata
@rm -rf /tmp/motorengine_test_2/mongotestdata && mkdir -p /tmp/motorengine_test_2/mongotestdata
@rm -rf /tmp/motorengine_test_3/mongotestdata && mkdir -p /tmp/motorengine_test_3/mongotestdata
Expand Down
5 changes: 1 addition & 4 deletions motorengine/aggregation/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,6 @@ def handle(*arguments, **kw):

results = []
for item in arguments[0]:
#if '_id' in item and isinstance(item['_id'], ObjectId):
#results.append(self.get_instance(item))
#else:
self.fill_ids(item)
results.append(edict(item))

Expand All @@ -159,7 +156,7 @@ def handle(*arguments, **kw):
@return_future
def fetch(self, callback=None, alias=None):
coll = self.queryset.coll(alias)
coll.aggregate(self.to_query()).to_list(None, callback=self.handle_aggregation(callback), cursor=False)
coll.aggregate(self.to_query()).to_list(None, callback=self.handle_aggregation(callback))

@classmethod
def avg(cls, field, alias=None):
Expand Down
8 changes: 5 additions & 3 deletions motorengine/metaclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ def __new__(cls, name, bases, attrs):
for attr_name, attr_value in attrs.items():
if not isinstance(attr_value, BaseField):
continue
if attr_value.__class__.__name__ == 'DynamicField':
continue
attr_value.name = attr_name
if not attr_value.db_field:
attr_value.db_field = attr_name
Expand Down Expand Up @@ -61,13 +63,13 @@ def __new__(cls, name, bases, attrs):

new_class = super_new(cls, name, bases, attrs)

if not '__collection__' in attrs:
if '__collection__' not in attrs:
new_class.__collection__ = new_class.__name__

if not '__lazy__' in attrs:
if '__lazy__' not in attrs:
new_class.__lazy__ = True

if not '__alias__' in attrs:
if '__alias__' not in attrs:
new_class.__alias__ = None

setattr(new_class, 'objects', classproperty(lambda *args, **kw: QuerySet(new_class)))
Expand Down
5 changes: 3 additions & 2 deletions tests/fields/test_dynamic_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ class TestDynamicField(AsyncTestCase):
def test_create_dynamic_field(self):
# we need a document to verify document's metaclass accepts the field
class TestDocument(Document):
dynamic_field = DynamicField(db_field="test")
dynamic_field = DynamicField(db_field="_test_something_name")

test_document = TestDocument()

expect(test_document.dynamic_field.db_field).to_equal("test")
expect(test_document.dynamic_field.db_field).to_equal("_test_something_name")
expect(test_document.dynamic_field.name).to_equal("test_something_name")

0 comments on commit 314685e

Please sign in to comment.