def get_schematics_models(app_name):
    app = get_app(app_name)
    models =  get_models(app)
    all_models = []
    for model in models:
        all_models += SchematicsModel.from_django(model)
    return all_models
    def test_simple_output(self):
        the_model = SchematicsModel.from_django(AModel)[0]
        output = """class AModel(Model):
    id = IntType(required=True)
    label = StringType(required=True, max_length=20)
    count = IntType(required=True)"""

        self.assertEqual(the_model.to_string(), output)
Esempio n. 3
0
    def test_simple_output(self):
        the_model = SchematicsModel.from_django(AModel)[0]
        output = """class AModel(Model):
    id = IntType(required=True)
    label = StringType(required=True, max_length=20)
    count = IntType(required=True)"""

        self.assertEqual(the_model.to_string(), output)
def get_output(apps_or_models, to_file=False, auto_file_name='domain_auto', ):
    data = get_models_to_output(*apps_or_models)
    full_buffer = []
    for app_name, models in data.items():
        this_buffer = []
        these_models = []
        for model in models:
            these_models += SchematicsModel.from_django(model)
        this_buffer = [model.to_string() for model in these_models]
        if to_file:
            app_dir = os.path.dirname(models[0].__module__)
            output_file = os.path.join(app_dir, app_name, '%s.py' % auto_file_name)
            open(output_file, 'w').write("".join(this_buffer))
        full_buffer += this_buffer
    if not to_file:
        return "\n\n" + "\n\n\n".join(full_buffer)
 def test_field_types(self):
     the_model = SchematicsModel.from_django(AModel)[0]
     self.assertEqual(type(the_model.fields[0]), IntegerFieldModel)
     self.assertEqual(type(the_model.fields[1]), CharFieldModel)
     self.assertEqual(type(the_model.fields[0]), IntegerFieldModel)
 def test_field_labels(self):
     the_model = SchematicsModel.from_django(AModel)[0]
     self.assertEqual(the_model.fields[0].name, 'id')
     self.assertEqual(the_model.fields[1].name, 'label')
     self.assertEqual(the_model.fields[2].name, 'count')
    def test_field_count(self):

        the_model = SchematicsModel.from_django(AModel)[0]
        # id comes by default
        self.assertEqual(len(the_model.fields), 3)
Esempio n. 8
0
 def test_field_types(self):
     the_model = SchematicsModel.from_django(AModel)[0]
     self.assertEqual(type(the_model.fields[0]), IntegerFieldModel)
     self.assertEqual(type(the_model.fields[1]), CharFieldModel)
     self.assertEqual(type(the_model.fields[0]), IntegerFieldModel)
Esempio n. 9
0
 def test_field_labels(self):
     the_model = SchematicsModel.from_django(AModel)[0]
     self.assertEqual(the_model.fields[0].name, 'id')
     self.assertEqual(the_model.fields[1].name, 'label')
     self.assertEqual(the_model.fields[2].name, 'count')
Esempio n. 10
0
    def test_field_count(self):

        the_model = SchematicsModel.from_django(AModel)[0]
        # id comes by default
        self.assertEqual(len(the_model.fields), 3)