def test_when_get_events_with_invalid_patition_then_partition_not_found( self): response = self.app.get('/topics/%s/events' % TEST_TOPIC, headers={ 'x-nakadi-cursors': '[{"partition": "%s", "offset": "0"}]' % TEST_PARTITIONS_NUM }) validate_error_response(response, 404, 'partition not found')
def test_when_post_not_compressed_events_with_compression_then_unprocessable_entity(self, events_num=10): events = [] for _ in range(events_num): events.append(test_common.create_dummy_event("dummy-key")) events_str = json.dumps(events) response = self.app.post( "/topics/%s/events/batch" % TEST_TOPIC, headers={"Content-Encoding": "gzip"}, data=events_str ) validate_error_response(response, 422, "Body decompression failed")
def test_when_post_not_compressed_events_with_compression_then_unprocessable_entity( self, events_num=10): events = [] for _ in range(events_num): events.append(test_common.create_dummy_event('dummy-key')) events_str = json.dumps(events) response = self.app.post('/topics/%s/events/batch' % TEST_TOPIC, headers={'Content-Encoding': 'gzip'}, data=events_str) validate_error_response(response, 422, 'Body decompression failed')
def test_when_get_events_with_invalid_nakadi_cursors_then_bad_syntax(self): headers_set = [ 'partition=0&offset=0', # not a json '{"partition": "0", "offset": "0"}', # not a list '[{"partition": "0", "new_offset": "0"}]', # doesn't have 'offset' field '[{"part": "0", "offset": "0"}]', # doesn't have 'partition' field '[{"partition": "a", "offset": "0"}]', # partition is not a number '[{"partition": "0", "offset": "a"}]' # offset is not a number ] for cursors in headers_set: response = self.app.get('/topics/%s/events' % TEST_TOPIC, headers={'x-nakadi-cursors': cursors}) validate_error_response(response, 400, '"x-nakadi-cursors" header has wrong format')
def test_when_get_events_with_invalid_nakadi_cursors_then_bad_syntax(self): headers_set = [ 'partition=0&offset=0', # not a json '{"partition": "0", "offset": "0"}', # not a list '[{"partition": "0", "new_offset": "0"}]', # doesn't have 'offset' field '[{"part": "0", "offset": "0"}]', # doesn't have 'partition' field '[{"partition": "a", "offset": "0"}]', # partition is not a number '[{"partition": "0", "offset": "a"}]' # offset is not a number ] for cursors in headers_set: response = self.app.get('/topics/%s/events' % TEST_TOPIC, headers={'x-nakadi-cursors': cursors}) validate_error_response( response, 400, '"x-nakadi-cursors" header has wrong format')
def test_when_get_events_with_invalid_patition_then_partition_not_found(self): response = self.app.get('/topics/%s/events' % TEST_TOPIC, headers={'x-nakadi-cursors': '[{"partition": "%s", "offset": "0"}]' % TEST_PARTITIONS_NUM}) validate_error_response(response, 404, 'partition not found')
def test_when_get_events_with_unknown_topic_then_topic_not_found(self): response = self.app.get('/topics/dummy-topic/events') validate_error_response(response, 404, 'topic not found')
def test_when_get_partitions_for_not_existing_topic_then_topic_not_found( self): response = self.app.get('/topics/not_existing_topic/partitions') validate_error_response(response, 404, 'topic not found')
def test_when_get_letter_partition_then_partition_not_a_number(self): response = self.app.get('/topics/%s/partitions/ab' % TEST_TOPIC) validate_error_response( response, 400, '"partition" path parameter should be an integer number')
def test_when_get_not_existing_partition_then_partition_not_found(self): response = self.app.get('/topics/%s/partitions/2341' % TEST_TOPIC) validate_error_response(response, 404, 'partition not found')
def test_when_get_partitions_for_not_existing_topic_then_topic_not_found(self): response = self.app.get("/topics/not_existing_topic/partitions") validate_error_response(response, 404, "topic not found")
def test_when_get_letter_partition_then_partition_not_a_number(self): response = self.app.get("/topics/%s/partitions/ab" % TEST_TOPIC) validate_error_response(response, 400, '"partition" path parameter should be an integer number')
def test_when_get_not_existing_partition_then_partition_not_found(self): response = self.app.get("/topics/%s/partitions/2341" % TEST_TOPIC) validate_error_response(response, 404, "partition not found")