From fb6852b38f6a7ff47a2161a8ca0a06dfae0e18f0 Mon Sep 17 00:00:00 2001 From: Emmanuelle Vargas-Gonzalez Date: Mon, 1 Mar 2021 20:47:30 -0500 Subject: [PATCH] update test suite --- stix2/test/v20/test_datastore_taxii.py | 2 ++ stix2/test/v21/test_datastore_taxii.py | 18 ++++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/stix2/test/v20/test_datastore_taxii.py b/stix2/test/v20/test_datastore_taxii.py index cd051f1..32aba92 100644 --- a/stix2/test/v20/test_datastore_taxii.py +++ b/stix2/test/v20/test_datastore_taxii.py @@ -53,6 +53,8 @@ class MockTAXIICollectionEndpoint(Collection): )[0] if objs: resp = Response() + resp.status_code = 200 + resp.headers["Content-Range"] = f"items 0-{len(objs)}/{len(objs)}" resp.encoding = "utf-8" resp._content = six.ensure_binary(stix2.v20.Bundle(objects=objs).serialize(ensure_ascii=False)) return resp diff --git a/stix2/test/v21/test_datastore_taxii.py b/stix2/test/v21/test_datastore_taxii.py index 92ae6dc..7a91f6f 100644 --- a/stix2/test/v21/test_datastore_taxii.py +++ b/stix2/test/v21/test_datastore_taxii.py @@ -29,14 +29,14 @@ class MockTAXIICollectionEndpoint(Collection): self._verify_can_write() if isinstance(bundle, six.string_types): bundle = json.loads(bundle) - for object in bundle.get("objects", []): - self.objects.append(object) + for obj in bundle.get("objects", []): + self.objects.append(obj) self.manifests.append( { "date_added": get_timestamp(), - "id": object["id"], + "id": obj["id"], "media_type": "application/stix+json;version=2.1", - "version": object.get("modified", object.get("created", get_timestamp())), + "version": obj.get("modified", obj.get("created", get_timestamp())), }, ) @@ -52,7 +52,10 @@ class MockTAXIICollectionEndpoint(Collection): 100, )[0] if objs: - return stix2.v21.Bundle(objects=objs) + return { + "objects": objs, + "more": False, + } else: resp = Response() resp.status_code = 404 @@ -76,7 +79,10 @@ class MockTAXIICollectionEndpoint(Collection): else: filtered_objects = [] if filtered_objects: - return stix2.v21.Bundle(objects=filtered_objects) + return { + "objects": filtered_objects, + "more": False, + } else: resp = Response() resp.status_code = 404