tests.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:openbare 作者: openbare 项目源码 文件源码
def test_set_username(self):
        """Test set username method."""
        # Test unicode converts to ascii J?hn to John
        with patch.object(AmazonAccountUtils,
                          'iam_user_exists',
                          return_value=False):
            self.aws_account._set_username()
            self.assertEqual(self.aws_account.username, 'John')

        # Test random username generated if iam user exists
        with patch.object(AmazonAccountUtils,
                          'iam_user_exists',
                          return_value=True):
            self.aws_account._set_username()
            self.assertNotEqual(self.aws_account.username, 'John')
            self.assertEqual(len(self.aws_account.username), 20)

        # Test random username is generated when regex invalid
        # after conversion. ??? converts to ???.
        self.user.username = '???'
        self.aws_account._set_username()
        self.assertNotEqual(self.aws_account.username, '???')
        self.assertEqual(len(self.aws_account.username), 20)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号