Skip to content
This repository has been archived by the owner on Sep 18, 2019. It is now read-only.

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
grewn0uille committed Feb 14, 2018
1 parent c591a97 commit 7f62eb9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
3 changes: 0 additions & 3 deletions sherlog/app.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import datetime
import time

from flask import Flask, g
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
Expand Down
7 changes: 5 additions & 2 deletions sherlog/log_parser.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
import configparser
import datetime
# datetime is needed because log contains datetime object
import datetime # noqa
import os
import time

from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker

from sherlog.model import Log


def get_config():
config_path = os.path.dirname(os.path.abspath(__file__))
path = os.getenv('PARSER_CFG', os.path.join(config_path, 'application.ini'))
path = os.getenv(
'PARSER_CFG', os.path.join(config_path, 'application.ini'))
config = configparser.ConfigParser()
config.read(path)
return config
Expand Down
23 changes: 18 additions & 5 deletions sherlog/tests/test_log_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def test_get_name_ping(one_line_ping):
def test_convert_to_dict_service(one_line_service):
title = one_line_service.split('(')[0]
assert (
log_parser.convert_to_dict(one_line_service.split(title)[1]) ==
log_parser.convert_to_dict(one_line_service.split(title)[1]) ==
{
'response': {
'code': 200,
Expand All @@ -32,7 +32,7 @@ def test_convert_to_dict_service(one_line_service):
'is_hard': False,
'status': 'info'
})


def test_convert_to_dict_ping(one_line_ping):
title = one_line_ping.split('(')[0]
Expand All @@ -46,7 +46,14 @@ def test_convert_to_dict_ping(one_line_ping):
'command': ['ping6', '-c1', '-W3', '2001:bc8:3261:500::1'],
'message': 'No message',
'ok': True,
'stdout': b'PING 2001:bc8:3261:500::1(2001:bc8:3261:500::1) 56 data bytes64 bytes from 2001:bc8:3261:500::1: icmp_seq=1 ttl=58 time=13.0 ms--- 2001:bc8:3261:500::1 ping statistics ---1 packets transmitted, 1 received, 0% packet loss, time 0msrtt min/avg/max/mdev = 13.072/13.072/13.072/0.000 ms',
'stdout': (
b'PING 2001:bc8:3261:500::1(2001:bc8:3261:500::1) '
b'56 data bytes64 bytes from 2001:bc8:3261:500::1: '
b'icmp_seq=1 ttl=58 time=13.0 ms--- 2001:bc8:3261:500::1 '
b'ping statistics ---1 packets transmitted, 1 received, '
b'0% packet loss, time 0msrtt min/avg/max/mdev = '
b'13.072/13.072/13.072/0.000 ms'
),
'timeout': False
},
'start': datetime.datetime(2018, 2, 9, 11, 20, 48, 952867),
Expand Down Expand Up @@ -75,7 +82,6 @@ def test_build_log_service(one_line_service):
})



def test_build_log_ping(one_line_ping):
title = one_line_ping.split('(')[0]
server_name = log_parser.get_name(title)
Expand All @@ -91,7 +97,14 @@ def test_build_log_ping(one_line_ping):
'stop': datetime.datetime(2018, 2, 9, 11, 20, 48, 976649),
'status': 'info',
'stderr': b'',
'stdout': b'PING 2001:bc8:3261:500::1(2001:bc8:3261:500::1) 56 data bytes64 bytes from 2001:bc8:3261:500::1: icmp_seq=1 ttl=58 time=13.0 ms--- 2001:bc8:3261:500::1 ping statistics ---1 packets transmitted, 1 received, 0% packet loss, time 0msrtt min/avg/max/mdev = 13.072/13.072/13.072/0.000 ms',
'stdout': (
b'PING 2001:bc8:3261:500::1(2001:bc8:3261:500::1) '
b'56 data bytes64 bytes from 2001:bc8:3261:500::1: '
b'icmp_seq=1 ttl=58 time=13.0 ms--- 2001:bc8:3261:500::1 '
b'ping statistics ---1 packets transmitted, 1 received, '
b'0% packet loss, time 0msrtt min/avg/max/mdev = '
b'13.072/13.072/13.072/0.000 ms'
),
'command': ['ping6', '-c1', '-W3', '2001:bc8:3261:500::1'],
'server_name': 'Anne-Laure'
})

0 comments on commit 7f62eb9

Please sign in to comment.