def setUp(self): super(UpdateManagerTest, self).setUp() self.test_wrapper = SearchTestWrapper(self.search_container) self.update_manager = self.search_container.update_manager data = [ utils.get_meta("test_key"), utils.get_meta("delete"), utils.get_meta("old"), # In another bucket utils.get_meta("other", "/other/artifact/other") ] self.test_wrapper.setup_metadata(data)
def setUp(self): super(ManagerTest, self).setUp() self.test_wrapper = SearchTestWrapper(self.search_container) self.manager = self.search_container.manager data = [ utils.get_meta(), utils.get_meta("other", "/this/that/other", "1.1"), utils.get_meta("thing", "/thing", "1.2"), utils.get_meta("blah", "/blah", "1.19"), utils.get_meta("a", "/a", "1.19"), utils.get_meta("zzzz", "/zzzz", "1.19"), ] self.test_wrapper.setup_metadata(data)
class UpdateManagerTest(UnitTestBase): def setUp(self): super(UpdateManagerTest, self).setUp() self.test_wrapper = SearchTestWrapper(self.search_container) self.update_manager = self.search_container.update_manager data = [ utils.get_meta("test_key"), utils.get_meta("delete"), utils.get_meta("old"), # In another bucket utils.get_meta("other", "/other/artifact/other") ] self.test_wrapper.setup_metadata(data) def tearDown(self): self.test_wrapper.teardown_metadata() def test_remove_all_old_docs(self): key_list = ["test_key"] deleted = self.update_manager.remove_unlisted_documents(key_list) self.assertEqual(3, deleted) self.assertEqual(None, self.test_wrapper.get_metadata("delete")) self.assertEqual(None, self.test_wrapper.get_metadata("old")) self.assertEqual(None, self.test_wrapper.get_metadata("other")) def test_remove_old_docs_per_bucket(self): key_list = ["test_key"] deleted = self.update_manager.remove_unlisted_documents_per_bucket(key_list, "test") self.assertEqual(2, deleted) self.assertEqual(None, self.test_wrapper.get_metadata("delete")) self.assertEqual(None, self.test_wrapper.get_metadata("old")) def test_remove_documents_wildcard(self): val_list = [ "/test/artifact/*" ] deleted = self.update_manager.remove_unlisted_documents_wildcard("artifactPath", val_list) self.assertEqual(1, deleted) self.assertEqual(None, self.test_wrapper.get_metadata("other")) def test_bulk_update(self): data = { "test_key": { "name": { "name": "name", "value": "value", "immutable": True } }, "test": { "name": { "name": "name", "value": "value", "immutable": False }, "die": { "name": "die", "value": "no one reads this anyway", "immutable": True } } } self.update_manager.bulk_update(data) first = self.update_manager._get_metadata("test_key").to_dict() second = self.update_manager._get_metadata("test").to_dict() expect_first = data["test_key"].values() expect_second = data["test"].values() self.assertEqual(first["property_list"], expect_first) self.assertEqual(second["property_list"], expect_second) def test_metadata_update(self): self.update_manager.update("test_key", utils.get_meta()) metadata = self.update_manager._get_metadata("test_key") self.assertEqual(metadata.to_dict(), {"property_list": utils.get_meta_elastic()})
class UpdateManagerTest(UnitTestBase): def setUp(self): super(UpdateManagerTest, self).setUp() self.test_wrapper = SearchTestWrapper(self.search_container) self.update_manager = self.search_container.update_manager data = [ utils.get_meta("test_key"), utils.get_meta("delete"), utils.get_meta("old"), # In another bucket utils.get_meta("other", "/other/artifact/other") ] self.test_wrapper.setup_metadata(data) def tearDown(self): self.test_wrapper.teardown_metadata() def test_remove_all_old_docs(self): key_list = ["test_key"] deleted = self.update_manager.remove_unlisted_documents(key_list) self.assertEqual(3, deleted) self.assertEqual(None, self.test_wrapper.get_metadata("delete")) self.assertEqual(None, self.test_wrapper.get_metadata("old")) self.assertEqual(None, self.test_wrapper.get_metadata("other")) def test_remove_old_docs_per_bucket(self): key_list = ["test_key"] deleted = self.update_manager.remove_unlisted_documents_per_bucket( key_list, "test") self.assertEqual(2, deleted) self.assertEqual(None, self.test_wrapper.get_metadata("delete")) self.assertEqual(None, self.test_wrapper.get_metadata("old")) def test_remove_documents_wildcard(self): val_list = ["/test/artifact/*"] deleted = self.update_manager.remove_unlisted_documents_wildcard( "artifactPath", val_list) self.assertEqual(1, deleted) self.assertEqual(None, self.test_wrapper.get_metadata("other")) def test_bulk_update(self): data = { "test_key": { "name": { "name": "name", "value": "value", "immutable": True } }, "test": { "name": { "name": "name", "value": "value", "immutable": False }, "die": { "name": "die", "value": "no one reads this anyway", "immutable": True } } } self.update_manager.bulk_update(data) first = self.update_manager._get_metadata("test_key").to_dict() second = self.update_manager._get_metadata("test").to_dict() expect_first = data["test_key"].values() expect_second = data["test"].values() self.assertEqual(first["property_list"], expect_first) self.assertEqual(second["property_list"], expect_second) def test_metadata_update(self): self.update_manager.update("test_key", utils.get_meta()) metadata = self.update_manager._get_metadata("test_key") self.assertEqual(metadata.to_dict(), {"property_list": utils.get_meta_elastic()})
class FunctionalTestBase(TestBase): RESPONSE_404 = { "message": "Resource not found", "code": ErrorCode.RESOURCE_NOT_FOUND } RESPONSE_403 = { "code": ErrorCode.FORBIDDEN, "message": "Forbidden" } RESPONSE_401 = { "code": ErrorCode.PERMISSION_DENIED, "message": "Permission denied" } RESPONSE_INVALID_NAME = { "message": "Artifact and directories names that BEGIN with an underscore are reserved as private " "and cannot be accessed or created. This of course exludes _search and _meta which are " "not part of the artifact path itself.", "code": ErrorCode.INVALID_ARTIFACT_NAME } RESPONSE_DUPLICATE = { "code": ErrorCode.DUPLICATE_ARTIFACT, "message": "Artifact by name test already exists in current directory" } RESPONSE_INVALID_FORMAT = { "code": ErrorCode.INVALID_REQUEST_DATA_FORMAT, "message": "Data sent with request must be in JSON format and also be either an array or an object.", } CONFIG = { "buckets": [ { "name": "test", "referenceName": "test", "accessKey": "test", "secretKey": "test" }, { "name": "bucket2", "referenceName": "b2", "accessKey": "test", "secretKey": "test" }, { "name": "thisBucketDoesntExistLol", "referenceName": "thisBucketDoesntExistLol", "accessKey": "fail", "secretKey": "fail" } ], "elasticsearch": { "connectionString": "http://localhost:9200/metadata", "upperSearchResultLimit": 100 } } def setUp(self): self.app = app self.setup_elastic() self.setup_moto() self.setup_metadata() self.test_client = app.test_client() self._route_tester = None self._metadata_comparator = None self.setup_storage() def setup_storage(self): """ This is important for comparing metadata later on because we "assertEqual" but the date would be different every time the test was run. The solution was to patch _to_utc to always return the same date. """ get_created_date = Mock(return_value=meta_utils.CREATED_DATE) MonkeyPatcher.patch(Initializer, "_get_created_date", get_created_date) @property def metadata_comparator(self): if not self._metadata_comparator: self._metadata_comparator = MetadataComparator( self, FunctionalTestBase.CONFIG["elasticsearch"]["connectionString"], app.logger) return self._metadata_comparator def assert_metadata_matches(self, resource_url, bucket_name=None): """ Makes the assumption that mock_s3 has been enabled (done in configure_moto). Makes sure that the metadata for a particular artifact is the same in the search layer and the cloud layer. Args: resource_url(basestring): The full path to the resource from the APIs perspective bucket_name(basestring): Optional. The name of the bucket the artifact will be stored in. Raises: AssertionError """ if not bucket_name: identity = ResourceIdentity(resource_url) for bucket_config in FunctionalTestBase.CONFIG["buckets"]: # identity.bucket_name is actually reference name. # TODO: Rename this. if identity.bucket_name == bucket_config["referenceName"]: bucket_name = bucket_config["name"] if not bucket_name: self.fail("bucket_name was not provided and we failed to look it up via FunctionalTestBase.CONFIG") self.metadata_comparator.compare(resource_url, bucket_name) @classmethod def setUpClass(cls): super(FunctionalTestBase, cls).setUpClass() configure.logger(app.logger, "DEBUG") app.config.update(cls.CONFIG) def setup_elastic(self): search_container = SearchContainer(self.app.logger, FunctionalTestBase.CONFIG["elasticsearch"]) self.search_wrapper = SearchTestWrapper(search_container) def setup_moto(self): self.moto_s3 = mock_s3() self.moto_s3.start() import httpretty # EXTREMELY IMPORTANT! If the port is not # appended httpretty does not identify it as http # but httplib does so the file pointer that # is supposed to be filled up by httpetty.fakesocket.socket # is not. httpretty.core.POTENTIAL_HTTP_PORTS.add(9200) self.boto_connection = boto.connect_s3() self.boto_connection.create_bucket("test") self.boto_connection.create_bucket("bucket2") self.test_bucket = self.boto_connection.get_bucket("test") self.setup_artifacts() self.create_auth_key() def setup_artifacts(self): self.create_key(self.test_bucket, "test", contents="hello world") self.create_key(self.test_bucket, "/dir/dir2/dir3/dir4/test5") self.create_key(self.test_bucket, "/dir/dir2/dir3/nest-test", contents="hello world") # "empty" has an empty metadata file. This is used when testing initialization # of metadata self.create_key(self.test_bucket, "empty", contents="hello world") self.create_key(self.test_bucket, "/_metadata_empty.yaml") self.create_key(self.test_bucket, "/dir/dir2/_secret", "No one should see this") self.create_key(self.test_bucket, "/dir/dir2/not_secret", "You can see this though") def create_key(self, bucket, artifact_name, contents=None): """ Creates an artifact in moto. Args: bucket(boto.s3.bucket.Bucket) artifact_name(string) contents(string | None) """ if contents is None: contents = "" key = Key(bucket, artifact_name) key.set_contents_from_string(contents) def setup_metadata(self): self.add_metadata("/test/artifact/test") self.add_metadata("/test/artifact/dir/dir2/dir3/nest-test") self.add_metadata("/test/artifact/this/that/other", "1.2") self.add_metadata("/test/artifact/thing", "1.2"), self.add_metadata("/test/artifact/blah", "1.19"), self.add_metadata("/test/artifact/a", "1.19"), self.add_metadata("/test/artifact/zzzz", "1.19"), self.add_metadata("/test/artifact/dir/dir2/Test", "2") self.search_wrapper.refresh_index() def add_metadata(self, resource_path, version="1", metadata=None): """ Adds metadata to moto and elastic. """ resource_id = ResourceIdentity(resource_path) data = meta_utils.get_meta(resource_id.artifact_name, resource_id.resource_path, version) if metadata: data.update(metadata) key = Key(self.boto_connection.get_bucket(resource_id.bucket_name), resource_id.cloud_metadata) key.set_contents_from_string(yaml.dump(data)) self.search_wrapper.add_metadata(resource_id.search, data) def create_auth_key(self): self.auth = utils.auth_header() key_name = "_keys/{0}".format(self.auth["Authorization"]) auth_key = Key(self.test_bucket, key_name) auth_key.set_contents_from_string(utils.get_permissions_func_test()) auth_bucket2 = Key(self.boto_connection.get_bucket("bucket2"), key_name) auth_bucket2.set_contents_from_string(utils.get_permissions_func_test()) def create_metadata_builder(self): return MetadataBuilder() @property def route_tester(self): if not self._route_tester: self._route_tester = Tester(self, self.test_client) return self._route_tester def tearDown(self): self.moto_s3.stop() self.search_wrapper.teardown_metadata() super(TestBase, self).tearDown() def response_500(self, message=None): if not message: message = "Internal server error" return { "message": message, "code": "internal_server_error" }
def setup_elastic(self): search_container = SearchContainer(self.app.logger, FunctionalTestBase.CONFIG["elasticsearch"]) self.search_wrapper = SearchTestWrapper(search_container)
class ManagerTest(UnitTestBase): def setUp(self): super(ManagerTest, self).setUp() self.test_wrapper = SearchTestWrapper(self.search_container) self.manager = self.search_container.manager data = [ utils.get_meta(), utils.get_meta("other", "/this/that/other", "1.1"), utils.get_meta("thing", "/thing", "1.2"), utils.get_meta("blah", "/blah", "1.19"), utils.get_meta("a", "/a", "1.19"), utils.get_meta("zzzz", "/zzzz", "1.19"), ] self.test_wrapper.setup_metadata(data) def tearDown(self): self.test_wrapper.teardown_metadata() def test_equality_search(self): results = self.manager.search({ "search": [ { "field": "artifactName", "search_type": SearchType.MATCH, "value": "test" }, { "field": "artifactPath", "search_type": SearchType.WILDCARD, "value": "/test/artifact/tes?" } ] }) expected = [utils.get_meta()] self.asserts.json_equals(expected, results) def test_no_match(self): results = self.manager.search({ "search": [ { "field": "artifactName", "search_type": SearchType.MATCH, "value": "neverrrrrrgonnamattttch" } ] }) self.asserts.json_equals([], results) def test_tilde_search(self): results = self.manager.search({ "search": [ { "field": "version", "search_type": SearchType.VERSION, "value": "1.1" } ] }) expected = [ utils.get_meta("a", "/a", "1.19"), utils.get_meta("blah", "/blah", "1.19"), utils.get_meta("other", "/this/that/other", "1.1"), utils.get_meta("thing", "/thing", "1.2"), utils.get_meta("zzzz", "/zzzz", "1.19"), ] self.asserts.json_equals(expected, results) def test_minor_version_search(self): results = self.manager.search({ "search": [ { "field": "version", "search_type": SearchType.VERSION, "value": "1.19" } ] }) expected = [ utils.get_meta("a", "/a", "1.19"), utils.get_meta("blah", "/blah", "1.19"), utils.get_meta("zzzz", "/zzzz", "1.19"), ] self.asserts.json_equals(expected, results) def test_select_fields(self): results = self.manager.search({ "search": [ { "field": "artifactName", "search_type": SearchType.MATCH, "value": "test" } ] }, ["artifactPath"]) expected = { "artifactPath": { "name": "artifactPath", "value": "/test/artifact/test", "immutable": True } } self.asserts.json_equals(expected, results[0]) def test_dumb_tilde_search(self): results = self.manager.search({ "search": [ { "field": "artifactName", "search_type": SearchType.VERSION, "value": "test" } ] }) expected = [ utils.get_meta(), utils.get_meta("thing", "/thing", "1.2"), utils.get_meta("zzzz", "/zzzz", "1.19"), ] self.asserts.json_equals(expected, results) def test_more_then_ten_results(self): data = [] # In setup 6 documents have already been added. Making an even 20. for i in range(14): data.append(utils.get_meta("mutli-test{0}".format(str(i)))) self.test_wrapper.setup_metadata(data) results = self.manager.search({ "search": [{ "field": "artifactName", "search_type": SearchType.WILDCARD, "value": "*" }] }) self.assertEqual(20, len(results)) def test_utils(self): connection = Connection("http://localhost:9200/index", "test", "test", "test") host = connection.transport.hosts[0] self.assertEqual("localhost", host["host"]) self.assertEqual(9200, host["port"]) self.assertEqual("index", connection.es_index) auth = connection.transport.get_connection().session.auth self.assertEqual("test", auth.aws_access_key) self.assertEqual("test", auth.aws_secret_access_key) self.assertEqual("localhost", auth.aws_host) self.assertEqual("test", auth.aws_region)
class FunctionalTestBase(TestBase): RESPONSE_404 = { "message": "Resource not found", "code": ErrorCode.RESOURCE_NOT_FOUND } RESPONSE_403 = {"code": ErrorCode.FORBIDDEN, "message": "Forbidden"} RESPONSE_401 = { "code": ErrorCode.PERMISSION_DENIED, "message": "Permission denied" } RESPONSE_INVALID_NAME = { "message": "Artifact and directories names that BEGIN with an underscore are reserved as private " "and cannot be accessed or created. This of course exludes _search and _meta which are " "not part of the artifact path itself.", "code": ErrorCode.INVALID_ARTIFACT_NAME } RESPONSE_DUPLICATE = { "code": ErrorCode.DUPLICATE_ARTIFACT, "message": "Artifact by name test already exists in current directory" } RESPONSE_INVALID_FORMAT = { "code": ErrorCode.INVALID_REQUEST_DATA_FORMAT, "message": "Data sent with request must be in JSON format and also be either an array or an object.", } CONFIG = { "buckets": [{ "name": "test", "referenceName": "test", "accessKey": "test", "secretKey": "test" }, { "name": "bucket2", "referenceName": "b2", "accessKey": "test", "secretKey": "test" }, { "name": "thisBucketDoesntExistLol", "referenceName": "thisBucketDoesntExistLol", "accessKey": "fail", "secretKey": "fail" }], "elasticsearch": { "connectionString": "http://localhost:9200/metadata", "upperSearchResultLimit": 100 } } def setUp(self): self.app = app self.setup_elastic() self.setup_moto() self.setup_metadata() self.test_client = app.test_client() self._route_tester = None self._metadata_comparator = None self.setup_storage() def setup_storage(self): """ This is important for comparing metadata later on because we "assertEqual" but the date would be different every time the test was run. The solution was to patch _to_utc to always return the same date. """ get_created_date = Mock(return_value=meta_utils.CREATED_DATE) MonkeyPatcher.patch(Initializer, "_get_created_date", get_created_date) @property def metadata_comparator(self): if not self._metadata_comparator: self._metadata_comparator = MetadataComparator( self, FunctionalTestBase.CONFIG["elasticsearch"]["connectionString"], app.logger) return self._metadata_comparator def assert_metadata_matches(self, resource_url): """ Makes the assumption that mock_s3 has been enabled (done in configure_moto). Makes sure that the metadata for a particular artifact is the same in the search layer and the cloud layer. Args: resource_url(basestring): The full path to the resource from the APIs perspective Raises: AssertionError """ self.metadata_comparator.compare(resource_url) @classmethod def setUpClass(cls): super(FunctionalTestBase, cls).setUpClass() configure.logger(app.logger, "DEBUG") app.config.update(cls.CONFIG) def setup_elastic(self): search_container = SearchContainer( self.app.logger, FunctionalTestBase.CONFIG["elasticsearch"]) self.search_wrapper = SearchTestWrapper(search_container) def setup_moto(self): self.moto_s3 = mock_s3() self.moto_s3.start() import httpretty # EXTREMELY IMPORTANT! If the port is not # appended httpretty does not identify it as http # but httplib does so the file pointer that # is supposed to be filled up by httpetty.fakesocket.socket # is not. httpretty.core.POTENTIAL_HTTP_PORTS.add(9200) self.boto_connection = boto.connect_s3() self.boto_connection.create_bucket("test") self.boto_connection.create_bucket("bucket2") self.test_bucket = self.boto_connection.get_bucket("test") self.setup_artifacts() self.create_auth_key() def setup_artifacts(self): self.create_key(self.test_bucket, "test", contents="hello world") self.create_key(self.test_bucket, "/dir/dir2/dir3/dir4/test5") self.create_key(self.test_bucket, "/dir/dir2/dir3/nest-test", contents="hello world") # "empty" has an empty metadata file. This is used when testing initialization # of metadata self.create_key(self.test_bucket, "empty", contents="hello world") self.create_key(self.test_bucket, "/_metadata_empty.yaml") self.create_key(self.test_bucket, "/dir/dir2/_secret", "No one should see this") self.create_key(self.test_bucket, "/dir/dir2/not_secret", "You can see this though") def create_key(self, bucket, artifact_name, contents=None): """ Creates an artifact in moto. Args: bucket(boto.s3.bucket.Bucket) artifact_name(string) contents(string | None) """ if contents is None: contents = "" key = Key(bucket, artifact_name) key.set_contents_from_string(contents) def setup_metadata(self): self.add_metadata("/test/artifact/test") self.add_metadata("/test/artifact/dir/dir2/dir3/nest-test") self.add_metadata("/test/artifact/this/that/other", "1.2") self.add_metadata("/test/artifact/thing", "1.2"), self.add_metadata("/test/artifact/blah", "1.19"), self.add_metadata("/test/artifact/a", "1.19"), self.add_metadata("/test/artifact/zzzz", "1.19"), self.add_metadata("/test/artifact/dir/dir2/Test", "2") self.search_wrapper.refresh_index() def add_metadata(self, resource_path, version="1", metadata=None): """ Adds metadata to moto and elastic. """ resource_id = ResourceIdentity(resource_path) data = meta_utils.get_meta(resource_id.artifact_name, resource_id.resource_path, version) if metadata: data.update(metadata) key = Key(self.boto_connection.get_bucket(resource_id.bucket_name), resource_id.cloud_metadata) key.set_contents_from_string(yaml.dump(data)) self.search_wrapper.add_metadata(resource_id.search, data) def create_auth_key(self): self.auth = utils.auth_header() key_name = "_keys/{0}".format(self.auth["Authorization"]) auth_key = Key(self.test_bucket, key_name) auth_key.set_contents_from_string(utils.get_permissions_func_test()) auth_bucket2 = Key(self.boto_connection.get_bucket("bucket2"), key_name) auth_bucket2.set_contents_from_string( utils.get_permissions_func_test()) def create_metadata_builder(self): return MetadataBuilder() @property def route_tester(self): if not self._route_tester: self._route_tester = Tester(self, self.test_client) return self._route_tester def tearDown(self): self.moto_s3.stop() self.search_wrapper.teardown_metadata() super(TestBase, self).tearDown() def response_500(self, message=None): if not message: message = "Internal server error" return {"message": message, "code": "internal_server_error"}
def setup_elastic(self): search_container = SearchContainer( self.app.logger, FunctionalTestBase.CONFIG["elasticsearch"]) self.search_wrapper = SearchTestWrapper(search_container)
class ManagerTest(UnitTestBase): def setUp(self): super(ManagerTest, self).setUp() self.test_wrapper = SearchTestWrapper(self.search_container) self.manager = self.search_container.manager data = [ utils.get_meta(), utils.get_meta("other", "/this/that/other", "1.1"), utils.get_meta("thing", "/thing", "1.2"), utils.get_meta("blah", "/blah", "1.19"), utils.get_meta("a", "/a", "1.19"), utils.get_meta("zzzz", "/zzzz", "1.19"), ] self.test_wrapper.setup_metadata(data) def tearDown(self): self.test_wrapper.teardown_metadata() def test_equality_search(self): results = self.manager.search({ "search": [{ "field": "artifactName", "search_type": SearchType.MATCH, "value": "test" }, { "field": "artifactPath", "search_type": SearchType.WILDCARD, "value": "/test/artifact/tes?" }] }) expected = [utils.get_meta()] self.asserts.json_equals(expected, results) def test_no_match(self): results = self.manager.search({ "search": [{ "field": "artifactName", "search_type": SearchType.MATCH, "value": "neverrrrrrgonnamattttch" }] }) self.asserts.json_equals([], results) def test_tilde_search(self): results = self.manager.search({ "search": [{ "field": "version", "search_type": SearchType.VERSION, "value": "1.1" }] }) expected = [ utils.get_meta("a", "/a", "1.19"), utils.get_meta("blah", "/blah", "1.19"), utils.get_meta("other", "/this/that/other", "1.1"), utils.get_meta("thing", "/thing", "1.2"), utils.get_meta("zzzz", "/zzzz", "1.19"), ] self.asserts.json_equals(expected, results) def test_minor_version_search(self): results = self.manager.search({ "search": [{ "field": "version", "search_type": SearchType.VERSION, "value": "1.19" }] }) expected = [ utils.get_meta("a", "/a", "1.19"), utils.get_meta("blah", "/blah", "1.19"), utils.get_meta("zzzz", "/zzzz", "1.19"), ] self.asserts.json_equals(expected, results) def test_select_fields(self): results = self.manager.search( { "search": [{ "field": "artifactName", "search_type": SearchType.MATCH, "value": "test" }] }, ["artifactPath"]) expected = { "artifactPath": { "name": "artifactPath", "value": "/test/artifact/test", "immutable": True } } self.asserts.json_equals(expected, results[0]) def test_dumb_tilde_search(self): results = self.manager.search({ "search": [{ "field": "artifactName", "search_type": SearchType.VERSION, "value": "test" }] }) expected = [ utils.get_meta(), utils.get_meta("thing", "/thing", "1.2"), utils.get_meta("zzzz", "/zzzz", "1.19"), ] self.asserts.json_equals(expected, results) def test_more_then_ten_results(self): data = [] # In setup 6 documents have already been added. Making an even 20. for i in range(14): data.append(utils.get_meta("mutli-test{0}".format(str(i)))) self.test_wrapper.setup_metadata(data) results = self.manager.search({ "search": [{ "field": "artifactName", "search_type": SearchType.WILDCARD, "value": "*" }] }) self.assertEqual(20, len(results)) def test_utils(self): connection = Connection("http://localhost:9200/index", "test", "test", "test") host = connection.transport.hosts[0] self.assertEqual("localhost", host["host"]) self.assertEqual(9200, host["port"]) self.assertEqual("index", connection.es_index) auth = connection.transport.get_connection().session.auth self.assertEqual("test", auth.aws_access_key) self.assertEqual("test", auth.aws_secret_access_key) self.assertEqual("localhost", auth.aws_host) self.assertEqual("test", auth.aws_region)