當前位置: 首頁>>代碼示例>>Python>>正文


Python MemcachedDatabase.add_password方法代碼示例

本文整理匯總了Python中database.memcached_database.MemcachedDatabase.add_password方法的典型用法代碼示例。如果您正苦於以下問題:Python MemcachedDatabase.add_password方法的具體用法?Python MemcachedDatabase.add_password怎麽用?Python MemcachedDatabase.add_password使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在database.memcached_database.MemcachedDatabase的用法示例。


在下文中一共展示了MemcachedDatabase.add_password方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_add_and_pop

# 需要導入模塊: from database.memcached_database import MemcachedDatabase [as 別名]
# 或者: from database.memcached_database.MemcachedDatabase import add_password [as 別名]
    def test_add_and_pop(self):
        '''Adds a password and pops it again.'''
        database = MemcachedDatabase()

        database.add_password("test_add_and_pop_8341")

        database.pop_password("test_add_and_pop_8341")
開發者ID:aidin36,項目名稱:beneath-a-binary-sky,代碼行數:9,代碼來源:test_add_password.py

示例2: test_bad_name

# 需要導入模塊: from database.memcached_database import MemcachedDatabase [as 別名]
# 或者: from database.memcached_database.MemcachedDatabase import add_password [as 別名]
    def test_bad_name(self):
        '''Tries to born a robot with an invalid name. Should be fail.'''
        population_control = PopulationControl()
        database = MemcachedDatabase()

        database.add_password("OIkdj981HJDJHcnm_1")
        database.add_password("OIkdj981HJDJHcnm_2")
        database.add_password("OIkdj981HJDJHcnm_3")
        database.add_password("OIkdj981HJDJHcnm_4")
        database.commit()

        long_name = "n" * (MAX_ROBOT_NAME + 1)
        with self.assertRaises(LongRobotNameError):
            population_control.execute_command("OIkdj981HJDJHcnm_1", "born", [None, long_name])
        database.rollback()

        with self.assertRaises(LongRobotNameError):
            population_control.execute_command("OIkdj981HJDJHcnm_2", "born", [None, None])
        database.rollback()

        with self.assertRaises(LongRobotNameError):
            population_control.execute_command("OIkdj981HJDJHcnm_3", "born", [None, b"some bytes"])
        database.rollback()

        with self.assertRaises(LongRobotNameError):
            population_control.execute_command("OIkdj981HJDJHcnm_4", "born", [None, database])
        database.rollback()
開發者ID:aidin36,項目名稱:beneath-a-binary-sky,代碼行數:29,代碼來源:test_born.py

示例3: test_duplicate_password

# 需要導入模塊: from database.memcached_database import MemcachedDatabase [as 別名]
# 或者: from database.memcached_database.MemcachedDatabase import add_password [as 別名]
    def test_duplicate_password(self):
        '''Adds a password twice. Should raise an exception.'''
        database = MemcachedDatabase()

        database.add_password("test_duplicate_8172")

        with self.assertRaises(DuplicatedPasswordError):
            database.add_password("test_duplicate_8172")
開發者ID:aidin36,項目名稱:beneath-a-binary-sky,代碼行數:10,代碼來源:test_add_password.py

示例4: test_double_pop

# 需要導入模塊: from database.memcached_database import MemcachedDatabase [as 別名]
# 或者: from database.memcached_database.MemcachedDatabase import add_password [as 別名]
    def test_double_pop(self):
        '''Tries to pop a password twice. Should raise an exception.'''
        database = MemcachedDatabase()

        database.add_password("test_double_pop_9864")

        database.pop_password("test_double_pop_9864")

        with self.assertRaises(InvalidPasswordError):
            database.pop_password("test_double_pop_9864")
開發者ID:aidin36,項目名稱:beneath-a-binary-sky,代碼行數:12,代碼來源:test_add_password.py

示例5: test_with_parent

# 需要導入模塊: from database.memcached_database import MemcachedDatabase [as 別名]
# 或者: from database.memcached_database.MemcachedDatabase import add_password [as 別名]
    def test_with_parent(self):
        '''Tests borning a robot with a parent.'''
        population_control = PopulationControl()
        database = MemcachedDatabase()

        database.add_password("oijdnnh76153WEd")
        robot = Robot("test_with_parent_18873", "123")
        database.add_robot(robot, (14, 1))
        database.commit()

        population_control.execute_command("oijdnnh76153WEd", "born", ["test_with_parent_18873", "My Child"])

        database.rollback()
開發者ID:aidin36,項目名稱:beneath-a-binary-sky,代碼行數:15,代碼來源:test_born.py

示例6: test_ok

# 需要導入模塊: from database.memcached_database import MemcachedDatabase [as 別名]
# 或者: from database.memcached_database.MemcachedDatabase import add_password [as 別名]
    def test_ok(self):
        '''Tests a good scenario.'''
        population_control = PopulationControl()
        database = MemcachedDatabase()

        database.add_password("iujeh87UYh6512ewQ")

        robot_info = population_control.execute_command("iujeh87UYh6512ewQ", "born", [None, "RDaniel"])
        database.commit()

        gotted_robot = database.get_robot(robot_info['robot_id'])

        self.assertEqual(gotted_robot.get_name(), "RDaniel")
開發者ID:aidin36,項目名稱:beneath-a-binary-sky,代碼行數:15,代碼來源:test_born.py

示例7: initialize_database

# 需要導入模塊: from database.memcached_database import MemcachedDatabase [as 別名]
# 或者: from database.memcached_database.MemcachedDatabase import add_password [as 別名]
def initialize_database(initial_passwords):
    database = MemcachedDatabase()
    database.initialize()

    for password in initial_passwords:
        database.add_password(password)
開發者ID:aidin36,項目名稱:beneath-a-binary-sky,代碼行數:8,代碼來源:start.py


注:本文中的database.memcached_database.MemcachedDatabase.add_password方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。