def testCreate(self):
        name = 'teste_%s' % str(datetime.now())
        obj = Interest.create(Interest(name=name))
        self.assertEqual(obj.name, name)
        self.assertTrue(is_integer(obj.id), 'ID was supposed to be int. Value: %s' % str(obj.id))

        try:
            name = 't' * 255
            obj = Interest.create(Interest(name=name))
            self.fail("Create interest should not succeed with invalid data")
        except ValidationException, e:
            self.assertTrue(True)
Exemple #2
0
def create():
    form = InterestCreateForm(request)
    if not form.validate():
        return json({'message': 'Validation Failed', 'errors': form.errors}, 422)

    data = Interest.create(Interest(name=form.name))
    if data.id == 0:
        return json({'message': 'Interest already exists'}, 409)

    return json(data, 201)
Exemple #3
0
def create():
    form = InterestCreateForm(request)
    if not form.validate():
        return json({
            'message': 'Validation Failed',
            'errors': form.errors
        }, 422)

    data = Interest.create(Interest(name=form.name))
    if data.id == 0:
        return json({'message': 'Interest already exists'}, 409)

    return json(data, 201)