xref: /unit/test/unit/applications/proto.py (revision 1027)
11019Szelenkov@nginx.comimport re
21019Szelenkov@nginx.comimport time
31019Szelenkov@nginx.comfrom unit.control import TestControl
41019Szelenkov@nginx.com
51019Szelenkov@nginx.com
61019Szelenkov@nginx.comclass TestApplicationProto(TestControl):
71019Szelenkov@nginx.com    def sec_epoch(self):
81019Szelenkov@nginx.com        return time.mktime(time.gmtime())
91019Szelenkov@nginx.com
101019Szelenkov@nginx.com    def date_to_sec_epoch(self, date, template='%a, %d %b %Y %H:%M:%S %Z'):
111019Szelenkov@nginx.com        return time.mktime(time.strptime(date, template))
121019Szelenkov@nginx.com
13*1027Szelenkov@nginx.com    def search_in_log(self, pattern, name='unit.log'):
14*1027Szelenkov@nginx.com        with open(self.testdir + '/' + name, 'r', errors='ignore') as f:
151019Szelenkov@nginx.com            return re.search(pattern, f.read())
16