yf_yzl 2 лет назад
Родитель
Сommit
f1290f2d3c
2 измененных файлов с 4403 добавлено и 3 удалено
  1. 14 3
      scripts/test/add_org_data.py
  2. 4389 0
      scripts/test/sa_pest_bank.json

+ 14 - 3
scripts/test/add_org_data.py

@@ -12,6 +12,7 @@ django.setup()
 from django.conf import settings
 from smartfarming.models.device import MongoDeviceType
 from smartfarming.models.user import UserPurview
+from smartfarming.models.pests_bank import MongoPestBank
 
 
 
@@ -23,14 +24,24 @@ with open(os.path.join(local_path, "scripts/test/sa_device_type.json") , 'r', en
             id=row.get("id"),
             defaults=row
         )
-        print(device_type, is_created)
+        print(device_type.id, is_created)
 
 
 with open(os.path.join(local_path, "scripts/test/sa_user_purview.json") , 'r', encoding='utf-8') as f:
     sa_user_purview = json.load(f)
     for row in sa_user_purview.get("rows"):
-        desa_user_purviewvice_type, is_created = UserPurview.objects.get_or_create(
+        sa_user_purview, is_created = UserPurview.objects.get_or_create(
             id=row.get("id"),
             defaults=row
         )
-        print(sa_user_purview, is_created)
+        print(sa_user_purview.id, is_created)
+
+
+with open(os.path.join(local_path, "scripts/test/sa_pest_bank.json") , 'r', encoding='utf-8') as f:
+    sa_pest_bank = json.load(f)
+    for row in sa_pest_bank.get("rows"):
+        sa_pest_bank, is_created = UserPurview.objects.get_or_create(
+            id=row.get("id"),
+            defaults=row
+        )
+        print(sa_pest_bank.id, is_created)

Разница между файлами не показана из-за своего большого размера
+ 4389 - 0
scripts/test/sa_pest_bank.json