Added shot summary per project on /attract
This commit is contained in:
@@ -47,6 +47,7 @@ class AbstractShotTest(AbstractAttractTest):
|
||||
self.assertIsInstance(shot, pillarsdk.Node)
|
||||
return shot
|
||||
|
||||
|
||||
class ShotManagerTest(AbstractShotTest):
|
||||
@responses.activate
|
||||
def test_tasks_for_shot(self):
|
||||
@@ -124,6 +125,26 @@ class ShotManagerTest(AbstractShotTest):
|
||||
self.assertEqual(u'Shoot the Pad Thai', found['description'])
|
||||
self.assertNotIn(u'notes', found['properties'])
|
||||
|
||||
@responses.activate
|
||||
def test_shot_summary(self):
|
||||
shot1 = self.create_shot()
|
||||
shot2 = self.create_shot()
|
||||
shot3 = self.create_shot()
|
||||
shot4 = self.create_shot()
|
||||
|
||||
with self.app.test_request_context():
|
||||
# Log in as project admin user
|
||||
pillar.auth.login_user(ctd.EXAMPLE_PROJECT_OWNER_ID)
|
||||
|
||||
self.mock_blenderid_validate_happy()
|
||||
for shot, status in zip([shot1, shot2, shot3, shot4],
|
||||
['todo', 'in_progress', 'todo', 'final']):
|
||||
self.smngr.edit_shot(shot_id=shot['_id'],
|
||||
status=status,
|
||||
_etag=shot._etag)
|
||||
|
||||
# def shot_status_summary(self, project_id):
|
||||
|
||||
|
||||
class NodeSetattrTest(unittest.TestCase):
|
||||
def test_simple(self):
|
||||
@@ -360,3 +381,35 @@ class RequiredAfterCreationTest(AbstractShotTest):
|
||||
|
||||
# TODO: should test editing a shot as well, but I had issues with the PillarSDK
|
||||
# not handling deleting of properties.
|
||||
|
||||
|
||||
class ProjectSummaryTest(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
from attract.shots import ProjectSummary
|
||||
|
||||
self.summ = ProjectSummary()
|
||||
self.summ.count(u'todo')
|
||||
self.summ.count(u'todo')
|
||||
self.summ.count(u'in-progress')
|
||||
self.summ.count(u'überhard')
|
||||
self.summ.count(u'Æon Flux')
|
||||
self.summ.count(u'Æon Flux')
|
||||
self.summ.count(u'in-progress')
|
||||
self.summ.count(u'todo')
|
||||
|
||||
def test_counting(self):
|
||||
self.assertEqual(8, self.summ._total)
|
||||
self.assertEqual(3, self.summ._counts[u'todo'])
|
||||
self.assertEqual(2, self.summ._counts[u'Æon Flux'])
|
||||
|
||||
def test_percentages(self):
|
||||
percs = list(self.summ.percentages())
|
||||
|
||||
self.assertEqual((u'in-progress', 25), percs[0])
|
||||
self.assertEqual((u'todo', 38), percs[1])
|
||||
self.assertEqual((u'Æon Flux', 25), percs[2])
|
||||
|
||||
# This should be rounded down, not rounded up, to ensure the sum of
|
||||
# percentages is 100.
|
||||
self.assertEqual((u'überhard', 12), percs[3])
|
||||
|
Reference in New Issue
Block a user