From 1faa2be3b493b823d64d96e7de89d7cc3865a29b Mon Sep 17 00:00:00 2001 From: Chris Church Date: Wed, 3 Dec 2014 20:13:08 -0500 Subject: [PATCH] Fix for active hosts count when running unit tests with SQLite. --- awx/main/managers.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/awx/main/managers.py b/awx/main/managers.py index 2fbe84a772..9ba978dc84 100644 --- a/awx/main/managers.py +++ b/awx/main/managers.py @@ -13,8 +13,10 @@ class HostManager(models.Manager): def active_count(self): """Return count of active, unique hosts for licensing.""" - return self.filter(active=True, inventory__active=True).distinct('name').count() - + try: + return self.filter(active=True, inventory__active=True).distinct('name').count() + except NotImplementedError: # For unit tests only, SQLite doesn't support distinct('name') + return len(set(self.filter(active=True, inventory__active=True).values_list('name', flat=True))) class InstanceManager(models.Manager): """A custom manager class for the Instance model.