Beispiel #1
0
    def test_simple(self):
        org = self.create_organization(name="test", status=OrganizationStatus.PENDING_DELETION)
        user = self.create_user()
        self.create_team(organization=org, name="test1")
        self.create_team(organization=org, name="test2")
        release = Release.objects.create(version="a" * 32, organization_id=org.id)
        repo = Repository.objects.create(organization_id=org.id, name=org.name, provider="dummy")
        commit_author = CommitAuthor.objects.create(
            organization_id=org.id, name="foo", email="*****@*****.**"
        )
        commit = Commit.objects.create(
            repository_id=repo.id, organization_id=org.id, author=commit_author, key="a" * 40
        )
        ReleaseCommit.objects.create(
            organization_id=org.id, release=release, commit=commit, order=0
        )

        env = Environment.objects.create(organization_id=org.id, project_id=4, name="foo")
        release_env = ReleaseEnvironment.objects.create(
            organization_id=org.id, project_id=4, release_id=release.id, environment_id=env.id
        )

        with self.tasks():
            with patch.object(DummyRepositoryProvider, "delete_repository") as mock_delete_repo:
                delete_organization(object_id=org.id, actor_id=user.id)
                assert mock_delete_repo.call_count == 1

        assert not Organization.objects.filter(id=org.id).exists()
        assert not Environment.objects.filter(id=env.id).exists()
        assert not ReleaseEnvironment.objects.filter(id=release_env.id).exists()
        assert not Repository.objects.filter(id=repo.id).exists()
        assert not ReleaseCommit.objects.filter(organization_id=org.id).exists()
        assert not Release.objects.filter(organization_id=org.id).exists()
        assert not CommitAuthor.objects.filter(id=commit_author.id).exists()
        assert not Commit.objects.filter(id=commit.id).exists()
Beispiel #2
0
    def test_simple(self):
        org = self.create_organization(
            name='test',
            status=OrganizationStatus.PENDING_DELETION,
        )
        self.create_team(organization=org, name='test1')
        self.create_team(organization=org, name='test2')
        repo = Repository.objects.create(
            organization_id=org.id,
            name=org.name,
        )
        commit_author = CommitAuthor.objects.create(
            organization_id=org.id,
            name='foo',
            email='*****@*****.**',
        )
        commit = Commit.objects.create(
            repository_id=repo.id,
            organization_id=org.id,
            author=commit_author,
            key='a' * 40,
        )
        with self.tasks():
            delete_organization(object_id=org.id)

        assert not Organization.objects.filter(id=org.id).exists()
        assert not Repository.objects.filter(id=repo.id).exists()
        assert not CommitAuthor.objects.filter(id=commit_author.id).exists()
        assert not Commit.objects.filter(id=commit.id).exists()
Beispiel #3
0
    def test_simple(self):
        org = self.create_organization(
            name='test',
            status=OrganizationStatus.PENDING_DELETION,
        )
        self.create_team(organization=org, name='test1')
        self.create_team(organization=org, name='test2')
        repo = Repository.objects.create(
            organization_id=org.id,
            name=org.name,
        )
        commit_author = CommitAuthor.objects.create(
            organization_id=org.id,
            name='foo',
            email='*****@*****.**',
        )
        commit = Commit.objects.create(
            repository_id=repo.id,
            organization_id=org.id,
            author=commit_author,
            key='a' * 40,
        )
        with self.tasks():
            delete_organization(object_id=org.id)

        assert not Organization.objects.filter(id=org.id).exists()
        assert not Repository.objects.filter(id=repo.id).exists()
        assert not CommitAuthor.objects.filter(id=commit_author.id).exists()
        assert not Commit.objects.filter(id=commit.id).exists()
Beispiel #4
0
    def test_simple(self):
        org = self.create_organization(
            name='test',
            status=OrganizationStatus.PENDING_DELETION,
        )
        user = self.create_user()
        self.create_team(organization=org, name='test1')
        self.create_team(organization=org, name='test2')
        release = Release.objects.create(version='a' * 32,
                                         organization_id=org.id)
        repo = Repository.objects.create(
            organization_id=org.id,
            name=org.name,
            provider='dummy',
        )
        commit_author = CommitAuthor.objects.create(
            organization_id=org.id,
            name='foo',
            email='*****@*****.**',
        )
        commit = Commit.objects.create(
            repository_id=repo.id,
            organization_id=org.id,
            author=commit_author,
            key='a' * 40,
        )
        ReleaseCommit.objects.create(
            organization_id=org.id,
            release=release,
            commit=commit,
            order=0,
        )

        env = Environment.objects.create(organization_id=org.id,
                                         project_id=4,
                                         name='foo')
        release_env = ReleaseEnvironment.objects.create(organization_id=org.id,
                                                        project_id=4,
                                                        release_id=release.id,
                                                        environment_id=env.id)

        with self.tasks():
            with patch.object(DummyRepositoryProvider,
                              'delete_repository') as mock_delete_repo:
                delete_organization(object_id=org.id, actor_id=user.id)
                mock_delete_repo.assert_called_once()  # NOQA

        assert not Organization.objects.filter(id=org.id).exists()
        assert not Environment.objects.filter(id=env.id).exists()
        assert not ReleaseEnvironment.objects.filter(
            id=release_env.id).exists()
        assert not Repository.objects.filter(id=repo.id).exists()
        assert not ReleaseCommit.objects.filter(
            organization_id=org.id).exists()
        assert not Release.objects.filter(organization_id=org.id).exists()
        assert not CommitAuthor.objects.filter(id=commit_author.id).exists()
        assert not Commit.objects.filter(id=commit.id).exists()
Beispiel #5
0
    def test_simple(self):
        org = self.create_organization(name="test", status=OrganizationStatus.PENDING_DELETION)
        self.create_team(organization=org, name="test1")
        self.create_team(organization=org, name="test2")

        with self.tasks():
            delete_organization(object_id=org.id)

        assert not Organization.objects.filter(id=org.id).exists()
Beispiel #6
0
    def test_cancels_without_pending_status(self):
        org = self.create_organization(name="test", status=OrganizationStatus.VISIBLE)
        self.create_team(organization=org, name="test1")
        self.create_team(organization=org, name="test2")

        with self.assertRaises(DeleteAborted):
            with self.tasks():
                delete_organization(object_id=org.id)

        assert Organization.objects.filter(id=org.id).exists()
Beispiel #7
0
    def test_simple(self):
        org = self.create_organization(
            name='test',
            status=OrganizationStatus.PENDING_DELETION,
        )
        self.create_team(organization=org, name='test1')
        self.create_team(organization=org, name='test2')
        release = Release.objects.create(version='a' * 32,
                                         organization_id=org.id)
        repo = Repository.objects.create(
            organization_id=org.id,
            name=org.name,
        )
        commit_author = CommitAuthor.objects.create(
            organization_id=org.id,
            name='foo',
            email='*****@*****.**',
        )
        commit = Commit.objects.create(
            repository_id=repo.id,
            organization_id=org.id,
            author=commit_author,
            key='a' * 40,
        )
        ReleaseCommit.objects.create(
            organization_id=org.id,
            release=release,
            commit=commit,
            order=0,
        )

        env = Environment.objects.create(
            organization_id=org.id,
            project_id=4,
            name='foo'
        )
        release_env = ReleaseEnvironment.objects.create(
            organization_id=org.id,
            project_id=4,
            release_id=release.id,
            environment_id=env.id
        )

        with self.tasks():
            delete_organization(object_id=org.id)

        assert not Organization.objects.filter(id=org.id).exists()
        assert not Environment.objects.filter(id=env.id).exists()
        assert not ReleaseEnvironment.objects.filter(id=release_env.id).exists()
        assert not Repository.objects.filter(id=repo.id).exists()
        assert not ReleaseCommit.objects.filter(organization_id=org.id).exists()
        assert not Release.objects.filter(organization_id=org.id).exists()
        assert not CommitAuthor.objects.filter(id=commit_author.id).exists()
        assert not Commit.objects.filter(id=commit.id).exists()
Beispiel #8
0
    def test_simple(self):
        org = self.create_organization(
            name='test',
            status=OrganizationStatus.PENDING_DELETION,
        )
        self.create_team(organization=org, name='test1')
        self.create_team(organization=org, name='test2')
        release = Release.objects.create(version='a' * 32,
                                         organization_id=org.id)
        repo = Repository.objects.create(
            organization_id=org.id,
            name=org.name,
        )
        commit_author = CommitAuthor.objects.create(
            organization_id=org.id,
            name='foo',
            email='*****@*****.**',
        )
        commit = Commit.objects.create(
            repository_id=repo.id,
            organization_id=org.id,
            author=commit_author,
            key='a' * 40,
        )
        ReleaseCommit.objects.create(
            organization_id=org.id,
            release=release,
            commit=commit,
            order=0,
        )

        env = Environment.objects.create(
            organization_id=org.id,
            project_id=4,
            name='foo'
        )
        release_env = ReleaseEnvironment.objects.create(
            organization_id=org.id,
            project_id=4,
            release_id=release.id,
            environment_id=env.id
        )

        with self.tasks():
            delete_organization(object_id=org.id)

        assert not Organization.objects.filter(id=org.id).exists()
        assert not Environment.objects.filter(id=env.id).exists()
        assert not ReleaseEnvironment.objects.filter(id=release_env.id).exists()
        assert not Repository.objects.filter(id=repo.id).exists()
        assert not ReleaseCommit.objects.filter(organization_id=org.id).exists()
        assert not Release.objects.filter(organization_id=org.id).exists()
        assert not CommitAuthor.objects.filter(id=commit_author.id).exists()
        assert not Commit.objects.filter(id=commit.id).exists()
Beispiel #9
0
    def test_simple(self):
        org = self.create_organization(
            name='test',
            status=OrganizationStatus.PENDING_DELETION,
        )
        self.create_team(organization=org, name='test1')
        self.create_team(organization=org, name='test2')

        with self.tasks():
            delete_organization(object_id=org.id)

        assert not Organization.objects.filter(id=org.id).exists()
Beispiel #10
0
    def test_cancels_without_pending_status(self):
        org = self.create_organization(
            name='test',
            status=OrganizationStatus.VISIBLE,
        )
        self.create_team(organization=org, name='test1')
        self.create_team(organization=org, name='test2')

        with self.assertRaises(DeleteAborted):
            with self.tasks():
                delete_organization(object_id=org.id)

        assert Organization.objects.filter(id=org.id).exists()
Beispiel #11
0
    def test_simple(self):
        org = self.create_organization(
            name='test',
            status=OrganizationStatus.PENDING_DELETION,
        )
        user = self.create_user()
        self.create_team(organization=org, name='test1')
        self.create_team(organization=org, name='test2')
        release = Release.objects.create(version='a' * 32, organization_id=org.id)
        repo = Repository.objects.create(
            organization_id=org.id,
            name=org.name,
            provider='dummy',
        )
        commit_author = CommitAuthor.objects.create(
            organization_id=org.id,
            name='foo',
            email='*****@*****.**',
        )
        commit = Commit.objects.create(
            repository_id=repo.id,
            organization_id=org.id,
            author=commit_author,
            key='a' * 40,
        )
        ReleaseCommit.objects.create(
            organization_id=org.id,
            release=release,
            commit=commit,
            order=0,
        )

        env = Environment.objects.create(organization_id=org.id, project_id=4, name='foo')
        release_env = ReleaseEnvironment.objects.create(
            organization_id=org.id, project_id=4, release_id=release.id, environment_id=env.id
        )

        with self.tasks():
            with patch.object(DummyRepositoryProvider, 'delete_repository') as mock_delete_repo:
                delete_organization(object_id=org.id, actor_id=user.id)
                mock_delete_repo.assert_called_once()  # NOQA

        assert not Organization.objects.filter(id=org.id).exists()
        assert not Environment.objects.filter(id=env.id).exists()
        assert not ReleaseEnvironment.objects.filter(id=release_env.id).exists()
        assert not Repository.objects.filter(id=repo.id).exists()
        assert not ReleaseCommit.objects.filter(organization_id=org.id).exists()
        assert not Release.objects.filter(organization_id=org.id).exists()
        assert not CommitAuthor.objects.filter(id=commit_author.id).exists()
        assert not Commit.objects.filter(id=commit.id).exists()