Ejemplo n.º 1
0
    def test_model(self):
        app = MockApp()
        model = Model('test', app=app)
        self.assertEqual([], model.fieldnames)
        with self.assertRaises(IndexError):
            self.assertEqual([], model.get_field_by_name('test'))

        model.validate({})
        model.find(test='test', test_two=['test'], test_three=False)
        model.to_repr()

        with self.assertRaises(Exception):
            model.create({})

        with self.assertRaises(Exception):
            model.update(_id='507f1f77bcf86cd799439011', data={})
Ejemplo n.º 2
0
def test_create_db_and_record():
    create_db_tables()

    gibson = Brand.create(name='Gibson')
    usa = SubBrand.create(name='USA', brand=gibson)
    les_paul = Range.create(name='Les Paul', brand=gibson)
    standard = Model.create(name='Standard', brand=gibson)
    guitar = Guitar.create(variant=None,
                           year=2018,
                           price=3399,
                           brand=gibson,
                           sub_brand=usa,
                           range_name=les_paul,
                           model=standard)