Exemple #1
0
def test_create_private(server, user, cycle_request, project):
    from girder.plugins.edp.models.cycle import Cycle

    r = server.request('/edp/projects/%s/cycles' % project['_id'],
                       method='POST',
                       body=json.dumps(cycle_request),
                       type='application/json',
                       user=user)
    assertStatus(r, 201)

    assert '_id' in r.json

    cycle = Cycle().load(r.json['_id'], force=True)
    assert cycle_request.items() <= cycle.items()
Exemple #2
0
def test_update(server, user, project, cycle):
    from girder.plugins.edp.models.cycle import Cycle

    updates = {'title': 'Nothing to see here.'}

    r = server.request('/edp/projects/%s/cycles/%s' %
                       (project['_id'], cycle['_id']),
                       method='PATCH',
                       body=json.dumps(updates),
                       type='application/json',
                       user=user)
    assertStatusOk(r)

    cycle = Cycle().load(r.json['_id'], force=True)
    assert updates.items() <= cycle.items()
Exemple #3
0
    def remove(self, project, user=None, force=False):
        super(Project, self).remove(project)

        for cycle in Cycle().query(project, force=True):
            if not force and not self.hasAccess(
                    cycle, user=user, level=AccessType.WRITE):
                raise ValidationException(
                    'Unable to remove cycle associated with project.')

            Cycle().remove(cycle, user)

        for postmortem in Postmortem().query(project, force=True):
            if not force and not self.hasAccess(
                    cycle, user=user, level=AccessType.WRITE):
                raise ValidationException(
                    'Unable to remove cycle associated with project.')

            Postmortem().remove(postmortem, user)
Exemple #4
0
def test_delete(server, user, project, cycle):
    from girder.plugins.edp.models.cycle import Cycle

    r = server.request('/edp/projects/%s/cycles/%s' %
                       (project['_id'], cycle['_id']),
                       method='DELETE',
                       user=user)
    assertStatusOk(r)

    cycle = Cycle().load(cycle['_id'], force=True)
    assert cycle is None
Exemple #5
0
def test_delete_with_cycle(server, user, project, cycle):
    from girder.plugins.edp.models.project import Project
    from girder.plugins.edp.models.cycle import Cycle

    r = server.request('/edp/projects/%s' % project['_id'],
                       method='DELETE', user=user)
    assertStatusOk(r)

    project = Project().load(project['_id'], force=True)
    assert project is None

    cycle = Cycle().load(cycle['_id'], force=True)
    assert cycle is None
Exemple #6
0
def make_cycle(server):
    from girder.plugins.edp.models.cycle import Cycle
    cycles = []

    def _make_cycle(user, project, request):
        r = server.request('/edp/projects/%s/cycles' % project['_id'], method='POST', body=json.dumps(request),
                           type='application/json', user=user)
        assertStatus(r, 201)
        cycles.append(r.json)

        return  r.json

    yield _make_cycle

    for cycle in cycles:
        Cycle().remove(cycle, force=True)