def createUser(): userDAO = UserDAO() user = User() user.username = "******" user.password = "******" group = Group() group.grouName = "admin" group.addUser(user) userDAO.save(user)
def test_save_and_get(connection_pool, test_table_name): _log.info(f'Started test with table name {test_table_name}') dao = UserDAO(connection_pool, test_table_name) dao.save(User('Pavel Andreievich Chekov', 15, 21)) # coordinates are specified as degrees of lat and long, distance is measured in meters expected_result = [SearchResult('Pavel Andreievich Chekov', 15, 21, 442977.30004328)] actual_result = dao.get_nearest(15, 25) assert actual_result == expected_result
def test_replace(connection_pool, test_table_name): _log.info(f'Started test with table name {test_table_name}') dao = UserDAO(connection_pool, test_table_name) dao.save(User('Pavel Andreievich Chekov', 15, 21)) dao.save(User('Pavel Andreievich Chekov', 1, 1)) # coordinates are specified as degrees of lat and long, distance is measured in meters expected_result = [SearchResult('Pavel Andreievich Chekov', 1, 1, 553912.06108329)] actual_result = dao.get_nearest(4, 5) assert actual_result == expected_result
def test_sorting(connection_pool, test_table_name): _log.info(f'Started test with table name {test_table_name}') dao = UserDAO(connection_pool, test_table_name) dao.save(User('Leonard McCoy', 3, 2)) dao.save(User('James Tiberius Kirk', 2, 3)) dao.save(User('Spock', 13, 25)) actual_result = dao.get_nearest(5, 8) assert \ [i.username for i in actual_result] == \ ['James Tiberius Kirk', 'Leonard McCoy', 'Spock']
from datamodels import User from datamodels import Group from dao import UserDAO user = User() user.username = "******" user.password = "******" admin = Group() admin.addUser(user) print(user) userDao = UserDAO() userDao.save()