Skip to content

Commit

Permalink
Fix hatch build includes (#1668)
Browse files Browse the repository at this point in the history
Worked fine in Docker. Not so much from pip
  • Loading branch information
untergeek committed Feb 16, 2023
1 parent 720e8fd commit 85f0ffe
Show file tree
Hide file tree
Showing 21 changed files with 637 additions and 603 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@ dist
docs/_build
docs/asciidoc/html_docs/
docker_test/repo/
docker_test/curatortestenv
docker_test/scripts/Dockerfile
elasticsearch_curator.egg-info
elasticsearch_curator_dev.egg-info
html_docs/
index.html
msi_guid.txt
nosetests.xml
samples
scratch
test/.DS_Store
1 change: 1 addition & 0 deletions curator/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Tending your Elasticsearch indices and snapshots"""
from curator._version import __version__
from curator.helpers import *
from curator.exceptions import *
from curator.defaults import *
from curator.validators import *
Expand Down
2 changes: 1 addition & 1 deletion curator/_version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"""Curator Version"""
__version__ = '8.0.2'
__version__ = '8.0.2.post1'
10 changes: 10 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ path = "curator/_version.py"
[tool.hatch.module]
name = "curator"

[tool.hatch.build]
include = [
"curator/*.py",
"curator/actions/*.py",
"curator/cli_singletons/*.py",
"curator/defaults/*.py",
"curator/helpers/*.py",
"curator/validators/*.py",
]

[tool.hatch.build.targets.sdist]
exclude = [
"dist",
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from elasticsearch8 import Elasticsearch
from elasticsearch8.exceptions import ConnectionError as ESConnectionError
from click import testing as clicktest
from curator import cli
from curator.cli import cli

from . import testvars
from unittest import SkipTest, TestCase
Expand Down
23 changes: 12 additions & 11 deletions tests/unit/test_action_clusterrouting.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
"""test_action_clusterrouting"""
from unittest import TestCase
from mock import Mock, patch
import curator
from mock import Mock
from curator.actions import ClusterRouting
# Get test variables and constants from a single source
from . import testvars as testvars
from . import testvars

class TestActionAllocation(TestCase):
def test_bad_client(self):
self.assertRaises(TypeError, curator.ClusterRouting, 'invalid', setting='enable')
self.assertRaises(TypeError, ClusterRouting, 'invalid', setting='enable')
def test_bad_setting(self):
client = Mock()
self.assertRaises(
ValueError, curator.ClusterRouting, client, setting='invalid'
ValueError, ClusterRouting, client, setting='invalid'
)
def test_bad_routing_type(self):
client = Mock()
self.assertRaises(
ValueError,
curator.ClusterRouting,
ClusterRouting,
client,
routing_type='invalid',
setting='enable'
Expand All @@ -25,7 +26,7 @@ def test_bad_value_with_allocation(self):
client = Mock()
self.assertRaises(
ValueError,
curator.ClusterRouting,
ClusterRouting,
client,
routing_type='allocation',
setting='enable',
Expand All @@ -35,15 +36,15 @@ def test_bad_value_with_rebalance(self):
client = Mock()
self.assertRaises(
ValueError,
curator.ClusterRouting,
ClusterRouting,
client,
routing_type='rebalance',
setting='enable',
value='invalid'
)
def test_do_dry_run(self):
client = Mock()
cro = curator.ClusterRouting(
cro = ClusterRouting(
client,
routing_type='allocation',
setting='enable',
Expand All @@ -54,7 +55,7 @@ def test_do_action_raise_on_put_settings(self):
client = Mock()
client.cluster.put_settings.return_value = None
client.cluster.put_settings.side_effect = testvars.fake_fail
cro = curator.ClusterRouting(
cro = ClusterRouting(
client,
routing_type='allocation',
setting='enable',
Expand All @@ -65,7 +66,7 @@ def test_do_action_wait(self):
client = Mock()
client.cluster.put_settings.return_value = None
client.cluster.health.return_value = {'relocating_shards':0}
cro = curator.ClusterRouting(
cro = ClusterRouting(
client,
routing_type='allocation',
setting='enable',
Expand Down
19 changes: 10 additions & 9 deletions tests/unit/test_action_create_index.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,35 @@
"""Unit tests for create_index action"""
from unittest import TestCase
from mock import Mock
import curator
from curator.actions import CreateIndex
from curator.exceptions import ConfigurationError, FailedExecution
# Get test variables and constants from a single source
from . import testvars

class TestActionCreate_index(TestCase):
def test_init_raise(self):
self.assertRaises(TypeError, curator.CreateIndex, name='name')
self.assertRaises(TypeError, CreateIndex, name='name')
def test_init_raise_no_name(self):
client = Mock()
self.assertRaises(curator.ConfigurationError,
curator.CreateIndex, client, name=None)
self.assertRaises(ConfigurationError,
CreateIndex, client, name=None)
def test_init(self):
client = Mock()
co = curator.CreateIndex(client, name='name')
co = CreateIndex(client, name='name')
self.assertEqual('name', co.name)
self.assertEqual(client, co.client)
def test_do_dry_run(self):
client = Mock()
co = curator.CreateIndex(client, name='name')
co = CreateIndex(client, name='name')
self.assertIsNone(co.do_dry_run())
def test_do_action(self):
client = Mock()
client.indices.create.return_value = None
co = curator.CreateIndex(client, name='name')
co = CreateIndex(client, name='name')
self.assertIsNone(co.do_action())
def test_do_action_raises_exception(self):
client = Mock()
client.indices.create.return_value = None
client.indices.create.side_effect = testvars.fake_fail
co = curator.CreateIndex(client, name='name')
self.assertRaises(curator.FailedExecution, co.do_action)
co = CreateIndex(client, name='name')
self.assertRaises(FailedExecution, co.do_action)
41 changes: 22 additions & 19 deletions tests/unit/test_action_delete_indices.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
"""test_action_delete_indices"""
from unittest import TestCase
from mock import Mock, patch
import curator
from mock import Mock
from curator.actions import DeleteIndices
from curator.exceptions import FailedExecution
from curator import IndexList
# Get test variables and constants from a single source
from . import testvars as testvars
from . import testvars

class TestActionDeleteIndices(TestCase):
def test_init_raise(self):
self.assertRaises(TypeError, curator.DeleteIndices, 'invalid')
self.assertRaises(TypeError, DeleteIndices, 'invalid')
def test_init_raise_bad_master_timeout(self):
client = Mock()
client.info.return_value = {'version': {'number': '5.0.0'} }
client.indices.get_settings.return_value = testvars.settings_one
client.cluster.state.return_value = testvars.clu_state_one
client.indices.stats.return_value = testvars.stats_one
ilo = curator.IndexList(client)
self.assertRaises(TypeError, curator.DeleteIndices, ilo, 'invalid')
ilo = IndexList(client)
self.assertRaises(TypeError, DeleteIndices, ilo, 'invalid')
def test_init(self):
client = Mock()
client.info.return_value = {'version': {'number': '5.0.0'} }
client.indices.get_settings.return_value = testvars.settings_one
client.cluster.state.return_value = testvars.clu_state_one
client.indices.stats.return_value = testvars.stats_one
ilo = curator.IndexList(client)
do = curator.DeleteIndices(ilo)
ilo = IndexList(client)
do = DeleteIndices(ilo)
self.assertEqual(ilo, do.index_list)
self.assertEqual(client, do.client)
def test_do_dry_run(self):
Expand All @@ -32,8 +35,8 @@ def test_do_dry_run(self):
client.cluster.state.return_value = testvars.clu_state_four
client.indices.stats.return_value = testvars.stats_four
client.indices.delete.return_value = None
ilo = curator.IndexList(client)
do = curator.DeleteIndices(ilo)
ilo = IndexList(client)
do = DeleteIndices(ilo)
self.assertIsNone(do.do_dry_run())
def test_do_action(self):
client = Mock()
Expand All @@ -42,8 +45,8 @@ def test_do_action(self):
client.cluster.state.return_value = testvars.clu_state_four
client.indices.stats.return_value = testvars.stats_four
client.indices.delete.return_value = None
ilo = curator.IndexList(client)
do = curator.DeleteIndices(ilo)
ilo = IndexList(client)
do = DeleteIndices(ilo)
self.assertIsNone(do.do_action())
def test_do_action_not_successful(self):
client = Mock()
Expand All @@ -52,8 +55,8 @@ def test_do_action_not_successful(self):
client.cluster.state.return_value = testvars.clu_state_four
client.indices.stats.return_value = testvars.stats_four
client.indices.delete.return_value = None
ilo = curator.IndexList(client)
do = curator.DeleteIndices(ilo)
ilo = IndexList(client)
do = DeleteIndices(ilo)
self.assertIsNone(do.do_action())
def test_do_action_raises_exception(self):
client = Mock()
Expand All @@ -63,16 +66,16 @@ def test_do_action_raises_exception(self):
client.indices.stats.return_value = testvars.stats_four
client.indices.delete.return_value = None
client.indices.delete.side_effect = testvars.fake_fail
ilo = curator.IndexList(client)
do = curator.DeleteIndices(ilo)
self.assertRaises(curator.FailedExecution, do.do_action)
ilo = IndexList(client)
do = DeleteIndices(ilo)
self.assertRaises(FailedExecution, do.do_action)
def test_verify_result_positive(self):
client = Mock()
client.info.return_value = {'version': {'number': '5.0.0'} }
client.indices.get_settings.return_value = testvars.settings_four
client.cluster.state.return_value = testvars.clu_state_four
client.indices.stats.return_value = testvars.stats_four
client.indices.delete.return_value = None
ilo = curator.IndexList(client)
do = curator.DeleteIndices(ilo)
ilo = IndexList(client)
do = DeleteIndices(ilo)
self.assertTrue(do._verify_result([],2))
31 changes: 17 additions & 14 deletions tests/unit/test_action_delete_snapshots.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
"""test_action_delete_snapshots"""
from unittest import TestCase
from mock import Mock, patch
import curator
from mock import Mock
from curator.actions import DeleteSnapshots
from curator.exceptions import FailedExecution
from curator import SnapshotList
# Get test variables and constants from a single source
from . import testvars as testvars

class TestActionDeleteSnapshots(TestCase):
def test_init_raise(self):
self.assertRaises(TypeError, curator.DeleteSnapshots, 'invalid')
self.assertRaises(TypeError, DeleteSnapshots, 'invalid')
def test_init(self):
client = Mock()
client.snapshot.get.return_value = testvars.snapshots
client.snapshot.get_repository.return_value = testvars.test_repo
slo = curator.SnapshotList(client, repository=testvars.repo_name)
do = curator.DeleteSnapshots(slo)
slo = SnapshotList(client, repository=testvars.repo_name)
do = DeleteSnapshots(slo)
self.assertEqual(slo, do.snapshot_list)
self.assertEqual(client, do.client)
def test_do_dry_run(self):
Expand All @@ -21,17 +24,17 @@ def test_do_dry_run(self):
client.snapshot.get_repository.return_value = testvars.test_repo
client.tasks.get.return_value = testvars.no_snap_tasks
client.snapshot.delete.return_value = None
slo = curator.SnapshotList(client, repository=testvars.repo_name)
do = curator.DeleteSnapshots(slo)
slo = SnapshotList(client, repository=testvars.repo_name)
do = DeleteSnapshots(slo)
self.assertIsNone(do.do_dry_run())
def test_do_action(self):
client = Mock()
client.snapshot.get.return_value = testvars.snapshots
client.snapshot.get_repository.return_value = testvars.test_repo
client.tasks.list.return_value = testvars.no_snap_tasks
client.snapshot.delete.return_value = None
slo = curator.SnapshotList(client, repository=testvars.repo_name)
do = curator.DeleteSnapshots(slo)
slo = SnapshotList(client, repository=testvars.repo_name)
do = DeleteSnapshots(slo)
self.assertIsNone(do.do_action())
def test_do_action_raises_exception(self):
client = Mock()
Expand All @@ -40,9 +43,9 @@ def test_do_action_raises_exception(self):
client.snapshot.delete.return_value = None
client.tasks.list.return_value = testvars.no_snap_tasks
client.snapshot.delete.side_effect = testvars.fake_fail
slo = curator.SnapshotList(client, repository=testvars.repo_name)
do = curator.DeleteSnapshots(slo)
self.assertRaises(curator.FailedExecution, do.do_action)
slo = SnapshotList(client, repository=testvars.repo_name)
do = DeleteSnapshots(slo)
self.assertRaises(FailedExecution, do.do_action)
### This check is not necessary after ES 7.16 as it is possible to have
### up to 1000 concurrent snapshots
###
Expand All @@ -57,6 +60,6 @@ def test_do_action_raises_exception(self):
# client.snapshot.get.return_value = testvars.inprogress
# client.snapshot.get_repository.return_value = testvars.test_repo
# client.tasks.list.return_value = testvars.no_snap_tasks
# slo = curator.SnapshotList(client, repository=testvars.repo_name)
# do = curator.DeleteSnapshots(slo, retry_interval=0, retry_count=1)
# slo = SnapshotList(client, repository=testvars.repo_name)
# do = DeleteSnapshots(slo, retry_interval=0, retry_count=1)
# self.assertRaises(curator.FailedExecution, do.do_action)

0 comments on commit 85f0ffe

Please sign in to comment.