Skip to content

Commit

Permalink
Updated to latest Dash
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanseymour committed Feb 11, 2016
1 parent 4819612 commit cab6ba0
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 40 deletions.
38 changes: 0 additions & 38 deletions casepro/dash_ext/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,3 @@
"""
A holding pen for code that will be merged into Dash
"""

import itertools
import six


class MockClientQuery(six.Iterator):
"""
Mock for APIv2 client get_xxxxx return values. Pass lists of temba objects to mock each fetch the client would make.
For example:
mock_get_contacts.return_value = MockClientQuery(
[TembaContact.create(...), TembaContact.create(...), TembaContact.create(...)]
[TembaContact.create(...)]
)
Will return the three contacts on the first call to iterfetches, and one on the second call.
"""
def __init__(self, *fetches):
self.fetches = list(fetches)

def iterfetches(self, retry_on_rate_exceed=False):
return self

def all(self, retry_on_rate_exceed=False):
return list(itertools.chain.from_iterable(self.fetches))

def first(self, retry_on_rate_exceed=False):
return self.fetches[0][0] if self.fetches[0] else None

def __iter__(self):
return self

def __next__(self):
if not self.fetches:
raise StopIteration()

return self.fetches.pop(0)
2 changes: 1 addition & 1 deletion casepro/dash_ext/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from casepro.contacts.models import Contact, Group, Field
from casepro.test import BaseCasesTest
from casepro.dash_ext import MockClientQuery
from dash.test import MockClientQuery
from django.utils import timezone
from mock import patch
from temba_client.v2.types import Group as TembaGroup, Field as TembaField
Expand Down
2 changes: 1 addition & 1 deletion pip-freeze.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ billiard==3.3.0.22
boto==2.38.0
celery==3.1.19
coverage==3.7.1
-e git+https://github.com/rapidpro/dash.git@8e67980667b002b5bc814eb17bb2f3bdb1589e27#egg=dash-master
-e git+https://github.com/rapidpro/dash.git@e2f81cde5f17ed2528e4a2c13b382af672ccd86c#egg=dash-master
dj-database-url==0.3.0
django-appconf==1.0.1
django-celery==3.1.17
Expand Down

0 comments on commit cab6ba0

Please sign in to comment.