from . import uuid


def task_crud(self, shotgun, trigger_poll=lambda: None):

    name = uuid(8)
    a = shotgun.create('Task', {'content': name})
    trigger_poll()
    b = self.cached.find_one('Task', [('id', 'is', a['id'])], ['content'])
    self.assertSameEntity(a, b)

    name += '-2'
    shotgun.update('Task', a['id'], {'content': name})
    trigger_poll()
    c = self.cached.find_one('Task', [('id', 'is', a['id'])], ['content'])
    self.assertEqual(c['content'], name)

    shotgun.delete('Task', a['id'])
    trigger_poll()
    d = self.cached.find_one('Task', [('id', 'is', a['id'])], ['content'])
    self.assertIs(d, None)

from . import uuid


def task_crud(self, shotgun, trigger_poll=lambda: None):

    shot_name = uuid(8)
    shot = shotgun.create('Shot', {'code': shot_name})

    name = uuid(8)
    task = shotgun.create('Task', {'content': name, 'entity': shot})
    trigger_poll()

    x = self.cached.find_one('Task', [('id', 'is', task['id'])], ['content'])
    self.assertSameEntity(task, x)

    # entity field
    x = self.cached.find_one('Task', [('id', 'is', task['id'])], ['entity'])
    self.assertSameEntity(shot, x['entity'])

    # return through entity field
    x = self.cached.find_one('Task', [('id', 'is', task['id'])], ['entity.Shot.code'])
    self.assertEqual(shot_name, x['entity.Shot.code'])

    # Updates
    name += '-2'
    shotgun.update('Task', task['id'], {'content': name})
    trigger_poll()
    x = self.cached.find_one('Task', [('id', 'is', task['id'])], ['content'])
    self.assertEqual(x['content'], name)

    # Delete
    shotgun.delete('Task', task['id'])
    trigger_poll()
    x = self.cached.find_one('Task', [('id', 'is', task['id'])], ['content'])
    self.assertIs(x, None)
    x = self.cached.find_one('Task', [('id', 'is', task['id'])], ['content'], retired_only=True)
    self.assertSameEntity(task, x)

Add entity link to basic crud tests
Add entity link to basic crud tests
