class TestLogModel(unittest.TestCase): def setUp(self): self.model = LogModel() self.logs = self.model.mongo.get_collection("logs") def test_get_logs(self): self.logs.remove() self.logs.insert({"tags": "info", "message": "test"}) self.logs.insert({"tags": "info", "message": "test"}) self.logs.insert({"tags": "info", "message": "test"}) result = self.model.get_logs() eq_(result["result"].count(), 3) self.logs.remove() def test_filtered_logs(self): self.logs.remove() self.logs.insert({"tags": "info", "message": "test", "_searchable": "test"}) self.logs.insert({"tags": "warning", "message": "test", "_searchable": "test_more"}) self.logs.insert({"tags": "debug", "message": "test", "_searchable": "another_thing"}) result = self.model.get_logs(["info"], None) eq_(result["result"].count(), 1) result = self.model.get_logs(["info", "debug"], None) eq_(result["result"].count(), 2) result = self.model.get_logs(["info", "debug", "warning"], None) eq_(result["result"].count(), 3) result = self.model.get_logs(["info"], "test") eq_(result["result"].count(), 1) result = self.model.get_logs([], "test") eq_(result["result"].count(), 2) self.logs.remove() def test_search_logs_by_tag(self): self.logs.remove() self.logs.insert({"tags": ["info"], "message": "test", "_searchable": "test"}) self.logs.insert({"tags": "info", "message": "test", "_searchable": "test"}) self.logs.insert({"tags": ["info", "debug"], "message": "test", "_searchable": "test"}) self.logs.insert({"tags": ["warning", "python"], "message": "test", "_searchable": "test"}) self.logs.insert({"tags": ["image", "test"], "message": "test", "_searchable": "test"}) result = self.model.get_logs(["info"], None) eq_(result["result"].count(), 3) result = self.model.get_logs(["debug"], None) eq_(result["result"].count(), 1) result = self.model.get_logs(["image"], None) eq_(result["result"].count(), 1) result = self.model.get_logs(["python"], None) eq_(result["result"].count(), 1)
class TestLogModel(unittest.TestCase): def setUp(self): self.model = LogModel() self.logs = self.model.mongo.get_collection('logs') def test_get_logs(self): self.logs.remove() self.logs.insert({"level": "info", "message": "test"}) self.logs.insert({"level": "info", "message": "test"}) self.logs.insert({"level": "info", "message": "test"}) result = self.model.get_logs() eq_(result.count(), 3) self.logs.remove() def test_filtered_logs(self): self.logs.remove() self.logs.insert({ "level": "info", "message": "test", "_searchable": "test" }) self.logs.insert({ "level": "warning", "message": "test", "_searchable": "test_more" }) self.logs.insert({ "level": "debug", "message": "test", "_searchable": "another_thing" }) result = self.model.filtered_logs(['info'], None) eq_(result.count(), 1) result = self.model.filtered_logs(['info', 'debug'], None) eq_(result.count(), 2) result = self.model.filtered_logs(['info', 'debug', 'warning'], None) eq_(result.count(), 3) result = self.model.filtered_logs(['info'], 'test') eq_(result.count(), 1) result = self.model.filtered_logs([], 'test') eq_(result.count(), 2) self.logs.remove()
class TestLogModel(unittest.TestCase): def setUp(self): self.model = LogModel() self.logs = self.model.mongo.get_collection('logs') def test_get_logs(self): self.logs.remove() self.logs.insert({"tags" : "info", "message" : "test"}) self.logs.insert({"tags" : "info", "message" : "test"}) self.logs.insert({"tags" : "info", "message" : "test"}) result = self.model.get_logs() eq_(result['result'].count(), 3) self.logs.remove() def test_filtered_logs(self): self.logs.remove() self.logs.insert({"tags" : "info", "message" : "test", "_searchable": "test"}) self.logs.insert({"tags" : "warning", "message" : "test", "_searchable": "test_more"}) self.logs.insert({"tags" : "debug", "message" : "test", "_searchable": "another_thing"}) result = self.model.get_logs(['info'], None) eq_(result['result'].count(), 1) result = self.model.get_logs(['info','debug'], None) eq_(result['result'].count(), 2) result = self.model.get_logs(['info','debug','warning'], None) eq_(result['result'].count(), 3) result = self.model.get_logs(['info'], 'test') eq_(result['result'].count(), 1) result = self.model.get_logs([], 'test') eq_(result['result'].count(), 2) self.logs.remove()
def setUp(self): self.model = LogModel() self.logs = self.model.mongo.get_collection('logs')
def setUp(self): self.model = LogModel() self.logs = self.model.mongo.get_collection("logs")
class TestLogModel(unittest.TestCase): def setUp(self): self.model = LogModel() self.logs = self.model.mongo.get_collection("logs") def test_get_logs(self): self.logs.remove() self.logs.insert({"tags": "info", "message": "test"}) self.logs.insert({"tags": "info", "message": "test"}) self.logs.insert({"tags": "info", "message": "test"}) result = self.model.get_logs() eq_(result["result"].count(), 3) self.logs.remove() def test_filtered_logs(self): self.logs.remove() self.logs.insert({"tags": "info", "message": "test", "_searchable": "test"}) self.logs.insert({"tags": "warning", "message": "test", "_searchable": "test_more"}) self.logs.insert({"tags": "debug", "message": "test", "_searchable": "another_thing"}) result = self.model.get_logs(["info"], None) eq_(result["result"].count(), 1) result = self.model.get_logs(["info", "debug"], filter="or") eq_(result["result"].count(), 2) result = self.model.get_logs(["info", "debug", "warning"], filter="or") eq_(result["result"].count(), 3) result = self.model.get_logs(["info"], "test") eq_(result["result"].count(), 1) result = self.model.get_logs([], search="test") eq_(result["result"].count(), 2) self.logs.remove() def test_search_logs_by_tag(self): self.logs.remove() self.logs.insert({"tags": ["info"], "message": "test", "_searchable": "test"}) self.logs.insert({"tags": "info", "message": "test", "_searchable": "test"}) self.logs.insert({"tags": ["info", "debug"], "message": "test", "_searchable": "test"}) self.logs.insert({"tags": ["warning", "python"], "message": "test", "_searchable": "test"}) self.logs.insert({"tags": ["image", "test"], "message": "test", "_searchable": "test"}) self.logs.insert({"tags": ["php", "notag"], "message": "test", "_searchable": "test"}) result = self.model.get_logs(["info"], None) eq_(result["result"].count(), 3) result = self.model.get_logs(["debug"], None) eq_(result["result"].count(), 1) result = self.model.get_logs(["image"], None) eq_(result["result"].count(), 1) result = self.model.get_logs(["python"], None) eq_(result["result"].count(), 1) def test_delete_before_date(self): self.logs.remove() self.logs.insert({"message": "test", "_searchable": "test", "time": now}) self.logs.insert({"message": "test", "_searchable": "test", "time": minute_ago}) self.logs.insert({"message": "test", "_searchable": "test", "time": two_minutes_ago}) self.model.delete_before_date(minute_ago) result = self.model.get_logs() eq_(result["result"].count(), 1) self.logs.remove()
class TestLogModel(unittest.TestCase): def setUp(self): self.model = LogModel() self.logs = self.model.mongo.get_collection('logs') def test_get_logs(self): self.logs.remove() self.logs.insert({"tags": "info", "message": "test"}) self.logs.insert({"tags": "info", "message": "test"}) self.logs.insert({"tags": "info", "message": "test"}) result = self.model.get_logs() eq_(result['result'].count(), 3) self.logs.remove() def test_filtered_logs(self): self.logs.remove() self.logs.insert({ "tags": "info", "message": "test", "_searchable": "test" }) self.logs.insert({ "tags": "warning", "message": "test", "_searchable": "test_more" }) self.logs.insert({ "tags": "debug", "message": "test", "_searchable": "another_thing" }) result = self.model.get_logs(['info'], None) eq_(result['result'].count(), 1) result = self.model.get_logs(['info', 'debug'], None) eq_(result['result'].count(), 2) result = self.model.get_logs(['info', 'debug', 'warning'], None) eq_(result['result'].count(), 3) result = self.model.get_logs(['info'], 'test') eq_(result['result'].count(), 1) result = self.model.get_logs([], 'test') eq_(result['result'].count(), 2) self.logs.remove() def test_search_logs_by_tag(self): self.logs.remove() self.logs.insert({ "tags": ["info"], "message": "test", "_searchable": "test" }) self.logs.insert({ "tags": "info", "message": "test", "_searchable": "test" }) self.logs.insert({ "tags": ["info", "debug"], "message": "test", "_searchable": "test" }) self.logs.insert({ "tags": ["warning", "python"], "message": "test", "_searchable": "test" }) self.logs.insert({ "tags": ["image", "test"], "message": "test", "_searchable": "test" }) result = self.model.get_logs(['info'], None) eq_(result['result'].count(), 3) result = self.model.get_logs(['debug'], None) eq_(result['result'].count(), 1) result = self.model.get_logs(['image'], None) eq_(result['result'].count(), 1) result = self.model.get_logs(['python'], None) eq_(result['result'].count(), 1)
class TestLogModel(unittest.TestCase): def setUp(self): self.model = LogModel() self.logs = self.model.mongo.get_collection('logs') def test_get_logs(self): self.logs.remove() self.logs.insert({"tags" : "info", "message" : "test"}) self.logs.insert({"tags" : "info", "message" : "test"}) self.logs.insert({"tags" : "info", "message" : "test"}) result = self.model.get_logs() eq_(result['result'].count(), 3) self.logs.remove() def test_filtered_logs(self): self.logs.remove() self.logs.insert({"tags" : "info", "message" : "test", "_searchable": "test"}) self.logs.insert({"tags" : "warning", "message" : "test", "_searchable": "test_more"}) self.logs.insert({"tags" : "debug", "message" : "test", "_searchable": "another_thing"}) result = self.model.get_logs(['info'], None) eq_(result['result'].count(), 1) result = self.model.get_logs(['info','debug'], None) eq_(result['result'].count(), 2) result = self.model.get_logs(['info','debug','warning'], None) eq_(result['result'].count(), 3) result = self.model.get_logs(['info'], 'test') eq_(result['result'].count(), 1) result = self.model.get_logs([], 'test') eq_(result['result'].count(), 2) self.logs.remove() def test_search_logs_by_tag(self): self.logs.remove() self.logs.insert({"tags" : ["info"] , "message" : "test", "_searchable": "test"}) self.logs.insert({"tags" : "info" , "message" : "test", "_searchable": "test"}) self.logs.insert({"tags" : ["info", "debug"] , "message" : "test", "_searchable": "test"}) self.logs.insert({"tags" : ["warning", "python"] , "message" : "test", "_searchable": "test"}) self.logs.insert({"tags" : ["image", "test"] , "message" : "test", "_searchable": "test"}) self.logs.insert({"tags" : ["php", "notag"] , "message" : "test", "_searchable": "test"}) result = self.model.get_logs(['info'], None) eq_(result['result'].count(), 3) result = self.model.get_logs(['debug'], None) eq_(result['result'].count(), 1) result = self.model.get_logs(['image'], None) eq_(result['result'].count(), 1) result = self.model.get_logs(['python'], None) eq_(result['result'].count(), 1) def test_delete_before_date(self): assert False