✨ Add stub script & execution of it in Dockerfile
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
parent
cb7dee9bf8
commit
0ecfcdc608
@ -0,0 +1,60 @@
|
|||||||
|
import pymongo
|
||||||
|
from datetime import datetime
|
||||||
|
from config import MONGODB_URL, MONGODB_USERNAME, MONGODB_PASSWORD, MONGODB_DATABASE
|
||||||
|
from utils import get_password_hash
|
||||||
|
|
||||||
|
client = pymongo.MongoClient(MONGODB_URL, username=MONGODB_USERNAME, password=MONGODB_PASSWORD)
|
||||||
|
db = client[MONGODB_DATABASE]
|
||||||
|
|
||||||
|
def populate_data():
|
||||||
|
users_collection = db["users"]
|
||||||
|
pins_collection = db["pins"]
|
||||||
|
|
||||||
|
user1_id = users_collection.insert_one({
|
||||||
|
"username": "string",
|
||||||
|
"password": get_password_hash("string")
|
||||||
|
}).inserted_id
|
||||||
|
|
||||||
|
user2_id = users_collection.insert_one({
|
||||||
|
"username": "test",
|
||||||
|
"password": get_password_hash("test")
|
||||||
|
}).inserted_id
|
||||||
|
|
||||||
|
pins_collection.insert_many([
|
||||||
|
{
|
||||||
|
"title": f"Tour Eiffel",
|
||||||
|
"description": "Description A",
|
||||||
|
"location": [48.858296, 2.294526],
|
||||||
|
"files": ["file_a"],
|
||||||
|
"owner": str(user1_id),
|
||||||
|
"created_at": datetime.utcnow()
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": f"Mont St Michel",
|
||||||
|
"description": "Description B",
|
||||||
|
"location": [48.636111, -1.511389],
|
||||||
|
"files": ["file_b"],
|
||||||
|
"owner": str(user1_id),
|
||||||
|
"created_at": datetime.utcnow()
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": f"Eiffel Tower",
|
||||||
|
"description": "Description X",
|
||||||
|
"location": [48.858296, 2.294526],
|
||||||
|
"files": ["file_x"],
|
||||||
|
"owner": str(user2_id),
|
||||||
|
"created_at": datetime.utcnow()
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": f"Mont Saint Michel",
|
||||||
|
"description": "Description Y",
|
||||||
|
"location": [48.636111, -1.511389],
|
||||||
|
"files": ["file_y"],
|
||||||
|
"owner": str(user2_id),
|
||||||
|
"created_at": datetime.utcnow()
|
||||||
|
}
|
||||||
|
])
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
populate_data()
|
||||||
|
print("Data inserted.")
|
Loading…
Reference in new issue