Esempio n. 1
0
 def test_create_fields(self):
     fields = [
         {"id": "name", "title": "Name", "type": "char"},
         {"id": "paycheck", "title": "Payment", "type": "int"},
         {"id": "date_joined", "title": "Job start date", "type": "date"}
     ]
     self.assertIsInstance(create_fields(fields)['name'], CharField)
     self.assertIsInstance(create_fields(fields)['paycheck'], IntegerField)
     self.assertIsInstance(create_fields(fields)['date_joined'], DateField)
Esempio n. 2
0
def add():

    if request.method == 'GET':
        return render_template('add.html')

    field_name = request.form.get('name_field')
    field_number = request.form.get('number_field')
    field_date = request.form.get('date_field')

    field = create_fields(field_name, field_number, field_date)
    return render_template('add.html', field=field)
Esempio n. 3
0
 def test_create_dynamic_models(self):
     name = "users_again"
     title = "Users"
     fields = [
         {"id": "name", "title": "Name", "type": "char"},
         {"id": "paycheck", "title": "Payment", "type": "int"},
         {"id": "date_joined", "title": "Job start date", "type": "date"}
     ]
     model = create_model(name, title, create_fields(fields))
     self.assertEqual(model.__name__, name)
     self.assertEqual(model._meta.verbose_name, title)
     self.assertEqual(len(model._meta.fields), 4)