コード例 #1
0
 def setUp(self):
     self.connection = connect_test()
     drop_db(self.connection)
     create_db(self.connection)
     user = User(name=self.name1, min_=0, max_=100, current=50)
     add_user(self.connection, user)
     user = User(name=self.name2, min_=0, max_=20, current=10)
     add_user(self.connection, user)
     self.connection.commit()
     self.connection2 = connect_test()
コード例 #2
0
 def test_insert(self):
     user = User(
         name="User1",
         min_=0,
         max_=100,
         current=10
     )
     add_user(self.connection, user)
     self.assertIsNotNone(user.id_)
     user2 = get_user(self.connection, user.name)
     self.assertEqual(user, user2)
コード例 #3
0
ファイル: add_user.py プロジェクト: Tishka17/sber_test
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from argparse import ArgumentParser

from connect import connect_production
from model import User
from model.use_cases import add_user

parser = ArgumentParser(description="Создание пользователя")
parser.add_argument("-n", "--name", required=True)
parser.add_argument("--min", dest="min_", default=0)
parser.add_argument("--max", dest="max_", required=True)
parser.add_argument("-c", "--current", help="Current money amount", default=0)

args = parser.parse_args()

with connect_production() as conn:
    user = User(name=args.name,
                min_=args.min_,
                max_=args.max_,
                current=args.current)
    add_user(conn, user)