Fix snapshot bug for cases when the snapshot has no creator

This commit is contained in:
Ramon Wenger 2022-04-14 16:41:10 +02:00
parent 693ecc2468
commit a9c01bd6d9
2 changed files with 11 additions and 1 deletions

View File

@ -168,7 +168,7 @@ class SnapshotNode(DjangoObjectType):
@staticmethod
def resolve_creator(parent, info, **kwargs):
return f'{parent.creator.first_name} {parent.creator.last_name}'
return f'{parent.creator.first_name} {parent.creator.last_name}' if parent.creator else ''
@staticmethod
def resolve_objective_groups(parent, info, **kwargs):

View File

@ -414,3 +414,13 @@ class SnapshotTestCase(SkillboxTestCase):
}
})
self.assertIsNotNone(result.get('errors'))
def test_snapshot_without_creator(self):
self.snapshot.creator = None
self.snapshot.shared = True
self.snapshot.save()
result = self.client.execute(MODULE_SNAPSHOTS_QUERY, variables={
"slug": self.slug
})
self.assertIsNone(result.get('errors'))
self.assertEqual(len(result.get('data').get('module').get('snapshots')), 1)