def test_by_date(self):
     data = json.loads(self.test_data_response.body)
     self.updateTestDataWithTestDates(data)
     parameters = {}
     parameters[START_DATE] = self.test_start_date_string
     parameters[IDS_ONLY] = False
     response = self._slice(parameters)
     date_int = helpers.convertDateTime(self.test_start_date_string)
     docs = json.loads(response.body)
     docs = docs['documents']
     assert len(docs) > 0
     assert len([x for x in docs if helpers.convertDateTime(x['resource_data_description']["node_timestamp"]) >= date_int]) == len(docs)
Ejemplo n.º 2
0
 def test_by_date(self):
     data = json.loads(self.test_data_response.body)
     self.updateTestDataWithTestDates(data)
     parameters = {}
     parameters[START_DATE] = self.test_start_date_string
     parameters[IDS_ONLY] = False
     response = self._slice(parameters)
     date_int = helpers.convertDateTime(self.test_start_date_string)
     docs = json.loads(response.body)
     docs = docs['documents']
     assert len(docs) > 0
     assert len([
         x for x in docs if helpers.convertDateTime(
             x['resource_data_description']["node_timestamp"]) >= date_int
     ]) == len(docs)
 def test_by_date_range_and_key(self):
     data = json.loads(self.test_data_response.body)
     self.updateTestDataWithMultipleTestDates(data, "test_by_date_range")
     parameters = {}
     parameters[START_DATE] = self.test_start_date_string
     parameters[END_DATE] = self.test_end_date_string
     parameters[ANY_TAGS] = self.testKeys[0] + 'test_by_date_range_and_key'
     parameters[IDS_ONLY] = False
     response = self._slice(parameters)
     docs = json.loads(response.body)
     docs = docs['documents']
     start_int = helpers.convertDateTime(self.test_start_date_string)
     end_int = helpers.convertDateTime(self.test_end_date_string)
     assert len(docs) > 0
     assert len([x for x in docs if start_int <= helpers.convertDateTime(x['resource_data_description']["node_timestamp"]) <= end_int]) == len(docs)
     assert len([x for x in docs if self.testKeys[0] + 'test_by_date_range_and_key' in x['resource_data_description']['keys']]) == len(docs)
Ejemplo n.º 4
0
    def test_resumption(self):
        slice_doc = helpers.getServiceDocument(config["lr.slice.docid"])
        page_size = slice_doc["service_data"]["doc_limit"]

        ##add test to assert that flow control is enabled, check that flow_control in service_data is true
        date_int = helpers.convertDateTime(self.test_start_date_string)
        parameters = {}
        parameters[START_DATE] = self.test_start_date_string
        parameters[IDS_ONLY] = False
        parameters[ANY_TAGS] = self.testKeys[0] + 'test_resumption'
        response = self._slice(parameters)
        result = json.loads(response.body)
        assert "resumption_token" in result
        test_key = self.testKeys[0] + 'test_resumption'

        def validate_page(docs):
            assert len(
                docs
            ) <= page_size, "resumption assert will fail. doc count is: " + str(
                len(docs))
            assert len([
                x for x in docs
                if helpers.convertDateTime(x['resource_data_description']
                                           ["node_timestamp"]) >= date_int
            ]) == len(docs)
            assert all(test_key in doc['resource_data_description']["keys"]
                       for doc in docs)

        self._validate_page(parameters, response, validate_page, 10)
 def test_by_date_range_and_identity(self):
     data = json.loads(self.test_data_response.body)
     self.updateTestDataWithMultipleTestDates(data, "test_by_date_range")
     parameters = {}
     parameters[START_DATE] = self.test_start_date_string
     parameters[END_DATE] = self.test_end_date_string
     parameters[IDENTITY] = self.identities[1] + "test_by_date_range_and_identity"
     parameters[IDS_ONLY] = False
     response = self._slice(parameters)
     docs = json.loads(response.body)
     docs = docs['documents']
     start_int = helpers.convertDateTime(self.test_start_date_string)
     end_int = helpers.convertDateTime(self.test_end_date_string)
     assert len(docs) > 0
     assert len([x for x in docs if start_int <= helpers.convertDateTime(x['resource_data_description']["node_timestamp"]) <= end_int]) == len(docs)
     for doc in docs:
         assert self._checkIdentity(doc['resource_data_description'], self.identities[1] + "test_by_date_range_and_identity")
Ejemplo n.º 6
0
 def validate_page(docs):
     assert len(
         docs
     ) <= page_size, "resumption assert will fail. doc count is: " + str(
         len(docs))
     assert len([
         x for x in docs
         if helpers.convertDateTime(x['resource_data_description']
                                    ["node_timestamp"]) >= date_int
     ]) == len(docs)
     assert all(test_key in doc['resource_data_description']["keys"]
                for doc in docs)
Ejemplo n.º 7
0
 def test_by_date_range_and_key(self):
     data = json.loads(self.test_data_response.body)
     self.updateTestDataWithMultipleTestDates(data, "test_by_date_range")
     parameters = {}
     parameters[START_DATE] = self.test_start_date_string
     parameters[END_DATE] = self.test_end_date_string
     parameters[ANY_TAGS] = self.testKeys[0] + 'test_by_date_range_and_key'
     parameters[IDS_ONLY] = False
     response = self._slice(parameters)
     docs = json.loads(response.body)
     docs = docs['documents']
     start_int = helpers.convertDateTime(self.test_start_date_string)
     end_int = helpers.convertDateTime(self.test_end_date_string)
     assert len(docs) > 0
     assert len([
         x for x in docs if start_int <= helpers.convertDateTime(
             x['resource_data_description']["node_timestamp"]) <= end_int
     ]) == len(docs)
     assert len([
         x for x in docs if self.testKeys[0] + 'test_by_date_range_and_key'
         in x['resource_data_description']['keys']
     ]) == len(docs)
Ejemplo n.º 8
0
 def test_by_date_range_and_identity(self):
     data = json.loads(self.test_data_response.body)
     self.updateTestDataWithMultipleTestDates(data, "test_by_date_range")
     parameters = {}
     parameters[START_DATE] = self.test_start_date_string
     parameters[END_DATE] = self.test_end_date_string
     parameters[
         IDENTITY] = self.identities[1] + "test_by_date_range_and_identity"
     parameters[IDS_ONLY] = False
     response = self._slice(parameters)
     docs = json.loads(response.body)
     docs = docs['documents']
     start_int = helpers.convertDateTime(self.test_start_date_string)
     end_int = helpers.convertDateTime(self.test_end_date_string)
     assert len(docs) > 0
     assert len([
         x for x in docs if start_int <= helpers.convertDateTime(
             x['resource_data_description']["node_timestamp"]) <= end_int
     ]) == len(docs)
     for doc in docs:
         assert self._checkIdentity(
             doc['resource_data_description'],
             self.identities[1] + "test_by_date_range_and_identity")
    def test_resumption(self):
        slice_doc = helpers.getServiceDocument(config["lr.slice.docid"])
        page_size = slice_doc["service_data"]["doc_limit"]

       ##add test to assert that flow control is enabled, check that flow_control in service_data is true
        date_int = helpers.convertDateTime(self.test_start_date_string)
        parameters = {}
        parameters[START_DATE] = self.test_start_date_string
        parameters[IDS_ONLY] = False
        parameters[ANY_TAGS] = self.testKeys[0] + 'test_resumption'
        response = self._slice(parameters)
        result = json.loads(response.body)
        assert "resumption_token" in result
        test_key = self.testKeys[0] + 'test_resumption'

        def validate_page(docs):
            assert len(docs) <= page_size, "resumption assert will fail. doc count is: " + str(len(docs))
            assert len([x for x in docs if helpers.convertDateTime(x['resource_data_description']["node_timestamp"]) >= date_int]) == len(docs)
            assert all(test_key in doc['resource_data_description']["keys"] for doc in docs)
        self._validate_page(parameters, response, validate_page, 10)
Ejemplo n.º 10
0
 def _get_dates(self, params):
     cur = h.convertDateTime(params.get(START_DATE, h.EPOCH_STRING))
     end = h.convertDateTime(params.get(END_DATE, datetime.utcnow().isoformat() + "Z"))
     return (cur, end)
 def validate_page(docs):
     assert len(docs) <= page_size, "resumption assert will fail. doc count is: " + str(len(docs))
     assert len([x for x in docs if helpers.convertDateTime(x['resource_data_description']["node_timestamp"]) >= date_int]) == len(docs)
     assert all(test_key in doc['resource_data_description']["keys"] for doc in docs)
Ejemplo n.º 12
0
 def _get_dates(self, params):
     cur = h.convertDateTime(params.get(START_DATE, h.EPOCH_STRING))
     end = h.convertDateTime(
         params.get(END_DATE,
                    datetime.utcnow().isoformat() + "Z"))
     return (cur, end)