当前位置: 首页>>代码示例>>Python>>正文


Python DataBase.is_same_users方法代码示例

本文整理汇总了Python中database.DataBase.is_same_users方法的典型用法代码示例。如果您正苦于以下问题:Python DataBase.is_same_users方法的具体用法?Python DataBase.is_same_users怎么用?Python DataBase.is_same_users使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在database.DataBase的用法示例。


在下文中一共展示了DataBase.is_same_users方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Test

# 需要导入模块: from database import DataBase [as 别名]
# 或者: from database.DataBase import is_same_users [as 别名]
class Test(unittest.TestCase):
    def setUp(self):
        self.db = DataBase()
        self.db._change_file_name('TestDatabase.db')
        self.friends_data = \
            [{'name': 'Vasya', 'bdate': '01.03.1998', 'skype': 'blabla'},
             {'name': 'Bob', 'bdate': '03.06.1876',
              'country': 'USA', 'city': 'Boston'}]
        self.db.create(data=(self.friends_data, None))

    def test_insert_user(self):
        user_data = {'name': 'Artyom', 'bdate':
                     '03.06.1997', 'country': 'Russia'}
        resp = self.db.insert_user(user_data)
        assert True, resp

    def test_get_user_inf(self):
        name = 'Vasya'
        name1 = 'Bob'
        data = self.db.get_user_inf(name)
        data1 = self.db.get_user_inf(name1)

        flag = data is not None and data1 is not None
        assert True, flag

    def test_update_user_inf(self):
        up_data = {'instagram': 'qwer'}
        self.db.update_user_inf('Bob', up_data)
        inf_user = self.db.get_user_inf('Bob')
        assert True, inf_user.get('instagram') is not None

    def test_delete_user(self):
        user = {'name': 'Artyom Soldatenko',
                'email': '[email protected]', 'bdate': '3.6.1997'}
        self.db.insert_user(user)
        self.db.delete_user(user['name'])
        res = self.db.contains_user(user['name'])
        assert True, not res

    def test_is_same_user_bdate(self):
        old_user = {'name': 'Artyom Soldatenko',
                    'email': '[email protected]', 'bdate': '03.06.1997'}
        user = {'name': 'Artyom Soldatenko',
                'email': '[email protected]', 'bdate': '3.6.1997'}
        res = self.db.is_same_users(old_user, user)
        assert True, res

    def test_is_same_user_not_inf(self):
        old_user = {'name': 'Artyom Soldatenko', 'email': '', 'bdate': ''}
        user = {'name': 'Artyom Soldatenko',
                'email': '[email protected]', 'bdate': '3.6.1997'}
        res = self.db.is_same_users(old_user, user)
        assert True, res

    def test_is_same_user_error(self):
        old_user = {'name': 'Artyom Soldatenko',
                    'email': '', 'bdate': '12.12.1998'}
        user = {'name': 'Artyom Soldatenko',
                'email': '[email protected]', 'bdate': '3.6.1997'}
        res = self.db.is_same_users(old_user, user)
        assert True, not res

    def test_contains_user(self):
        user = {'name': 'Artyom Soldatenko'}
        self.db.insert_user(user)
        assert True, self.db.contains_user(user['name'])

    def test_merge_users(self):
        old_user = {'name': 'Artyom Soldatenko', 'email': '', 'bdate': ''}
        self.db.insert_user(old_user)
        user = {'name': 'Artyom Soldatenko',
                'email': '[email protected]', 'bdate': '3.6.1997'}
        self.db.merge_user(old_user, user)
        res = self.db.contains_user('Artyom Soldatenko')
        new_user = self.db.get_user_inf('Artyom Soldatenko')
        res1 = new_user['email'] == '[email protected]' and \
            new_user['bdate'] == '3.6.1997'
        assert True, res and res1
开发者ID:vakyym07,项目名称:export_contacts,代码行数:80,代码来源:test_database.py


注:本文中的database.DataBase.is_same_users方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。