diff --git a/common/cpp/src/database/mongodb_client.cpp b/common/cpp/src/database/mongodb_client.cpp index 43a97531831d3dc097c7256fe7a45fca003297b0..2d27c3c87434a8a54aabfd3abffacbb2fe12739a 100644 --- a/common/cpp/src/database/mongodb_client.cpp +++ b/common/cpp/src/database/mongodb_client.cpp @@ -428,6 +428,9 @@ Error MongoDBClient::GetStreamInfo(const std::string &collection, StreamInfo* in std::string last_record_str, earliest_record_str; auto err = GetRecordFromDb(collection, 0, GetRecordMode::kLast, &last_record_str); if (err) { + if (err == DBErrorTemplates::kNoRecord) { // with noRecord error it will return last_id = 0 which can be used to understand that the stream is not started yet + return nullptr; + } return err; } err = GetRecordFromDb(collection, 0, GetRecordMode::kEarliest, &earliest_record_str); diff --git a/tests/automatic/producer/python_api/producer_api.py b/tests/automatic/producer/python_api/producer_api.py index 10c981da4702ac11d2f9a154d3346482f816d753..2d6de1c5321425cf5f37bcd76ae72c6aa1a1bb7a 100644 --- a/tests/automatic/producer/python_api/producer_api.py +++ b/tests/automatic/producer/python_api/producer_api.py @@ -187,19 +187,20 @@ info = producer.stream_info('stream') assert_eq(info['lastId'], 3, "last id from different stream") assert_eq(info['finished'], True, "stream finished") +info = producer.stream_info('not_exist') +assert_eq(info['lastId'], 0, "last id from non existing stream") + + info_last = producer.last_stream() assert_eq(info_last['name'], "stream", "last stream") assert_eq(info_last['timestampCreated'] <= info_last['timestampLast'], True, "last is later than first") #delete_streams producer.delete_stream('stream') -try: - producer.stream_info('stream') -except asapo_producer.AsapoWrongInputError as e: - print(e) -else: - print("should be error on stream info after stream was deleted") - sys.exit(1) +producer.stream_info('stream') +assert_eq(info['lastId'], 0, "last id from non deleted stream") + + producer.delete_stream('unknown_stream',error_on_not_exist = False) try: producer.delete_stream('unknown_stream',error_on_not_exist = True)