Exemplo n.º 1
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
Exemplo n.º 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
Exemplo n.º 3
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()
Exemplo n.º 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()
Exemplo n.º 5
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')
Exemplo n.º 6
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')
Exemplo n.º 7
0
 def test_delete_user_twice(self):
     user_create('charlie', 'foo')
     user_delete('charlie')
     with pytest.raises(api.NotFoundError):
         user_delete('charlie')
Exemplo n.º 8
0
 def test_delete_user(self):
     user_create('charlie', 'foo')
     user_delete('charlie')
Exemplo n.º 9
0
 def test_duplicate_user(self):
     user_create('charlie', 'secret')
     with pytest.raises(api.DuplicateError):
             user_create('charlie', 'password')
Exemplo n.º 10
0
 def test_new_user(self):
     api._assert_absent(User, 'charlie')
     user_create('charlie', 'foo')
Exemplo n.º 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')
Exemplo n.º 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')
Exemplo n.º 13
0
 def test_delete_user_twice(self):
     user_create('charlie', 'foo')
     user_delete('charlie')
     with pytest.raises(api.NotFoundError):
         user_delete('charlie')
Exemplo n.º 14
0
 def test_delete_user(self):
     user_create('charlie', 'foo')
     user_delete('charlie')
Exemplo n.º 15
0
 def test_duplicate_user(self):
     user_create('charlie', 'secret')
     with pytest.raises(api.DuplicateError):
             user_create('charlie', 'password')
Exemplo n.º 16
0
 def test_new_user(self):
     api._assert_absent(User, 'charlie')
     user_create('charlie', 'foo')