Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixed broken tests on mobile

  • Loading branch information...
commit 0e5bb3d1acb19d8affe109e9b26f7bb87c8e1bc9 1 parent ad9c99d
@peterbe peterbe authored
Showing with 38 additions and 4 deletions.
  1. +35 −3 pto/apps/mobile/tests.py
  2. +3 −1 pto/apps/mobile/views.py
View
38 pto/apps/mobile/tests.py
@@ -117,6 +117,9 @@ def test_right_now_json(self):
harry = User.objects.create_user(
'harry', 'harry@mozilla.com',
)
+ mike = User.objects.create_user(
+ 'mike', 'mike@mozilla.com',
+ )
today = datetime.date.today()
@@ -148,15 +151,44 @@ def test_right_now_json(self):
end=today + datetime.timedelta(days=2),
)
- self._login()
+ user = self._login()
+ response = self.client.get(url)
+ eq_(response.status_code, 200)
+ struct = json.loads(response.content)
+ eq_(len(struct['now']), 0)
+ eq_(len(struct['upcoming']), 0)
+
+ # nothing is returned because the current isnt' following
+ # these people
+ profile = user.get_profile()
+ profile.manager = mike.email
+ profile.save()
+
+ profile = freddy.get_profile()
+ profile.manager = mike.email
+ profile.save()
+
+ profile = bobby.get_profile()
+ profile.manager = mike.email
+ profile.save()
+
+ profile = dicky.get_profile()
+ profile.manager = mike.email
+ profile.save()
+
+ profile = harry.get_profile()
+ profile.manager = mike.email
+ profile.save()
+
response = self.client.get(url)
eq_(response.status_code, 200)
struct = json.loads(response.content)
eq_(len(struct['now']), 2)
eq_(len(struct['upcoming']), 1)
+
names = [x['name'] for x in struct['now']]
- ok_('dicky' in names[0])
- ok_('freddy' in names[1])
+ ok_('freddy' in names[0])
+ ok_('dicky' in names[1])
names = [x['name'] for x in struct['upcoming']]
ok_('harry' in names[0])
View
4 pto/apps/mobile/views.py
@@ -53,12 +53,14 @@ def right_now(request):
start = today = datetime.datetime.utcnow()
end = start + datetime.timedelta(days=90)
+
for entry in (Entry.objects
.filter(user__in=user_ids,
total_hours__gte=0,
total_hours__isnull=False)
.select_related('user')
- .exclude(Q(end__lt=start) | Q(start__gt=end))):
+ .order_by('start')
+ .exclude(Q(end__lt=start) | Q(start__gte=end))):
row = {}
name = entry.user.get_full_name()
if not name:
Please sign in to comment.
Something went wrong with that request. Please try again.