示例#1
0
文件: database.py 项目: gsilvis/haas
 def test_user_add_project(self):
     user_create('charlie', 'secret')
     api.project_create('acme-corp')
     user_add_project('charlie', 'acme-corp')
     user = api._must_find(User, 'charlie')
     project = api._must_find(model.Project, 'acme-corp')
     assert project in user.projects
     assert user in project.users
示例#2
0
 def test_user_add_project(self):
     user_create('charlie', 'secret')
     api.project_create('acme-corp')
     user_add_project('charlie', 'acme-corp')
     user = api._must_find(User, 'charlie')
     project = api._must_find(model.Project, 'acme-corp')
     assert project in user.projects
     assert user in project.users
示例#3
0
文件: database.py 项目: gsilvis/haas
    def _new_user(self, is_admin):
        """Helper method for creating/switching to a new user.

        A new admin user will be created with the credentials:

        username: '******'
        password: '******'

        The argument is_admin determines whether the user has admin rights.

        Once the user has been created, the authentication info will be
        changed to that user.
        """
        user_create('charlie', 'foo', is_admin=is_admin)
        flask.request = FakeAuthRequest('charlie', 'foo')
        local.auth = User.query.filter_by(label='charlie').one()
示例#4
0
    def _new_user(self, is_admin):
        """Helper method for creating/switching to a new user.

        A new admin user will be created with the credentials:

        username: '******'
        password: '******'

        The argument is_admin determines whether the user has admin rights.

        Once the user has been created, the authentication info will be
        changed to that user.
        """
        user_create('charlie', 'foo', is_admin=is_admin)
        flask.request = FakeAuthRequest('charlie', 'foo')
        local.auth = User.query.filter_by(label='charlie').one()
示例#5
0
文件: database.py 项目: gsilvis/haas
 def test_bad_user_remove_project(self):
     """Tests that removing a user from a project they're not in fails."""
     user_create('charlie', 'secret')
     api.project_create('acme-corp')
     with pytest.raises(api.NotFoundError):
         user_remove_project('charlie', 'acme-corp')
示例#6
0
文件: database.py 项目: gsilvis/haas
 def test_duplicate_user_add_project(self):
     user_create('charlie', 'secret')
     api.project_create('acme-corp')
     user_add_project('charlie', 'acme-corp')
     with pytest.raises(api.DuplicateError):
         user_add_project('charlie', 'acme-corp')
示例#7
0
文件: database.py 项目: gsilvis/haas
 def test_delete_user_twice(self):
     user_create('charlie', 'foo')
     user_delete('charlie')
     with pytest.raises(api.NotFoundError):
         user_delete('charlie')
示例#8
0
文件: database.py 项目: gsilvis/haas
 def test_delete_user(self):
     user_create('charlie', 'foo')
     user_delete('charlie')
示例#9
0
文件: database.py 项目: gsilvis/haas
 def test_duplicate_user(self):
     user_create('charlie', 'secret')
     with pytest.raises(api.DuplicateError):
             user_create('charlie', 'password')
示例#10
0
文件: database.py 项目: gsilvis/haas
 def test_new_user(self):
     api._assert_absent(User, 'charlie')
     user_create('charlie', 'foo')
示例#11
0
 def test_bad_user_remove_project(self):
     """Tests that removing a user from a project they're not in fails."""
     user_create('charlie', 'secret')
     api.project_create('acme-corp')
     with pytest.raises(api.NotFoundError):
         user_remove_project('charlie', 'acme-corp')
示例#12
0
 def test_duplicate_user_add_project(self):
     user_create('charlie', 'secret')
     api.project_create('acme-corp')
     user_add_project('charlie', 'acme-corp')
     with pytest.raises(api.DuplicateError):
         user_add_project('charlie', 'acme-corp')
示例#13
0
 def test_delete_user_twice(self):
     user_create('charlie', 'foo')
     user_delete('charlie')
     with pytest.raises(api.NotFoundError):
         user_delete('charlie')
示例#14
0
 def test_delete_user(self):
     user_create('charlie', 'foo')
     user_delete('charlie')
示例#15
0
 def test_duplicate_user(self):
     user_create('charlie', 'secret')
     with pytest.raises(api.DuplicateError):
             user_create('charlie', 'password')
示例#16
0
 def test_new_user(self):
     api._assert_absent(User, 'charlie')
     user_create('charlie', 'foo')