Browse Source

Automatic Commit By liuyuqi

fish 2 weeks ago
parent
commit
b41c421751
3 changed files with 23 additions and 1 deletions
  1. 8 1
      models.py
  2. 0 0
      test/__init__.py
  3. 15 0
      test/my_unittest.py

+ 8 - 1
models.py

@@ -4,6 +4,13 @@ from datetime import datetime
 db = SQLAlchemy()
 
 class ImageModel(db.Model):
-    """ 用户 """
+    """ image model """
     id = db.Column(db.Integer, primary_key=True)
+    image = db.Column(db.LargeBinary, nullable=False)
+    created_at = db.Column(db.DateTime, default=datetime.utcnow)
+    updated_at = db.Column(db.DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
+    
+    def __init__(self, image):
+        self.image = image
+        
     

+ 0 - 0
test/__init__.py


+ 15 - 0
test/my_unittest.py

@@ -0,0 +1,15 @@
+import unittest
+from flask_image_matcher.models import ImageModel
+
+class TestImageModel(unittest.TestCase):
+
+    def test_init(self):
+        # Test with valid image
+        image = b'valid_image_data'
+        model = ImageModel(image)
+        self.assertEqual(model.image, image)
+
+        # Test with empty image
+        image = b''
+        with self.assertRaises(ValueError):
+            ImageModel(image)