Exemplo n.º 1
0
class TestGetData(unittest.TestCase):
    def setUp(self):
        self.url = "http://127.0.0.1:5000"
        self.simplelog = Simplelog(self.url)
        self.simplelog.error({'ip': '127.0.0.1', 'name': 'Test'}, "This is a test!", ["simplelogs", "test"])
        self.simplelog.warning({'ip': '127.0.0.1', 'name': 'Test'}, "This is a test!", ["simplelogs", "test"])
        self.simplelog.info({'ip': '127.0.0.1', 'name': 'Test'}, "This is a test!", ["simplelogs", "test"])

    def test_get_owners(self):
        owners = self.simplelog.get_owners()
        self.assertIsNotNone(owners)
        self.assertTrue(owners['OK'])
        self.assertIn({'ip': '127.0.0.1', 'name': 'Test'}, owners['result'])

    def test_get_list(self):
        result = self.simplelog.get_list(find=dict(level='error', owner='Test'))
        self.assertIsNotNone(result)
        self.assertTrue(result['OK'])
        entry = result['result'][0]
        self.assertTrue('OK' in result and
                        result['OK'] and
                        entry['level'] == 'error' and
                        entry['owner'] == {'ip': '127.0.0.1', 'name': 'Test'} and
                        entry['data'] == "This is a test!" and
                        entry['tags'] == ["simplelogs", "test"],
                        msg="Server response is not the same as entry in DB.")

    def test_count(self):
        count = self.simplelog.count(find=dict(level='warning', owner='Test'))
        self.assertIsNotNone(count)
        self.assertTrue(count['OK'])
        self.assertGreaterEqual(count['result'], 1)
Exemplo n.º 2
0
 def setUp(self):
     self.url = "http://127.0.0.1:5000"
     self.simplelog = Simplelog(self.url)
     self.simplelog.error({'ip': '127.0.0.1', 'name': 'Test'}, "This is a test!", ["simplelogs", "test"])
     self.simplelog.warning({'ip': '127.0.0.1', 'name': 'Test'}, "This is a test!", ["simplelogs", "test"])
     self.simplelog.info({'ip': '127.0.0.1', 'name': 'Test'}, "This is a test!", ["simplelogs", "test"])