# Path: test/simple.py
# class Base(unittest.TestCase):
#     config = CONFIG
# 
#     def setUp(self):
#         self.do_init()
#         time.sleep(START_TIMEOUT)
# 
#     def do_init(self):
#         self.proc = subprocess.Popen([ZEROGW_BINARY, '-c', self.config])
#         self.addCleanup(stop_process, self.proc)
# 
#     def http(self, host='localhost'):
#         conn = http.HTTPConnection(host, timeout=1.0)
#         conn.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
#         for i in range(100):
#             try:
#                 conn.sock.connect(HTTP_ADDR)
#             except socket.error:
#                 time.sleep(0.1)
#                 continue
#             else:
#                 break
#         else:
#             raise RuntimeError("Can't connect to zerogw")
#         return conn
# 
#     def websock(self, **kw):
#         return CheckingWebsock(self, **kw)


import os
import gzip
    import unittest
from .simple import Base
        self.addCleanup(conn.close)
        conn.request('GET', '/test/testfile.txt')
        resp = conn.getresponse()
        self.assertEqual(resp.headers['Content-Type'], 'text/plain')
        self.assertTrue(resp.headers['Date'])
        txt = resp.read().decode('ascii')
        self.assertEqual(txt, 'test\nfile\n')

    def testIfModifiedSince(self):
        conn = self.http()
        self.addCleanup(conn.close)
        conn.request('GET', '/test/testfile.txt')
        resp = conn.getresponse()
        self.assertEqual(resp.headers['Content-Type'], 'text/plain')
        lm = resp.headers['Last-Modified']
        txt = resp.read().decode('ascii')
        self.assertEqual(txt, 'test\nfile\n')
        conn.request('GET', '/test/testfile.txt',
            headers={'If-Modified-Since': lm})
        resp = conn.getresponse()
        self.assertEqual(resp.code, 304)
        txt = resp.read().decode('ascii')
        self.assertEqual(txt, '')
        os.utime("test/testfile.txt", None)
        conn.request('GET', '/test/testfile.txt',
            headers={'If-Modified-Since': lm})
        resp = conn.getresponse()
        lm1 = resp.headers['Last-Modified']
        txt = resp.read().decode('ascii')
        self.assertEqual(txt, 'test\nfile\n')

# Path: test/simple.py
# class Base(unittest.TestCase):
#     config = CONFIG
# 
#     def setUp(self):
#         self.do_init()
#         time.sleep(START_TIMEOUT)
# 
#     def do_init(self):
#         self.proc = subprocess.Popen([ZEROGW_BINARY, '-c', self.config])
#         self.addCleanup(stop_process, self.proc)
# 
#     def http(self, host='localhost'):
#         conn = http.HTTPConnection(host, timeout=1.0)
#         conn.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
#         for i in range(100):
#             try:
#                 conn.sock.connect(HTTP_ADDR)
#             except socket.error:
#                 time.sleep(0.1)
#                 continue
#             else:
#                 break
#         else:
#             raise RuntimeError("Can't connect to zerogw")
#         return conn
# 
#     def websock(self, **kw):
#         return CheckingWebsock(self, **kw)


# Path: test/static.py
import os
import gzip
    import unittest
from .simple import Base

        self.addCleanup(conn.close)
        conn.request('GET', '/test/testfile.txt')
        resp = conn.getresponse()
        self.assertEqual(resp.headers['Content-Type'], 'text/plain')
        self.assertTrue(resp.headers['Date'])
        txt = resp.read().decode('ascii')
        self.assertEqual(txt, 'test\nfile\n')

    def testIfModifiedSince(self):
        conn = self.http()
        self.addCleanup(conn.close)
        conn.request('GET', '/test/testfile.txt')
        resp = conn.getresponse()
        self.assertEqual(resp.headers['Content-Type'], 'text/plain')
        lm = resp.headers['Last-Modified']
        txt = resp.read().decode('ascii')
        self.assertEqual(txt, 'test\nfile\n')
        conn.request('GET', '/test/testfile.txt',
            headers={'If-Modified-Since': lm})
        resp = conn.getresponse()
        self.assertEqual(resp.code, 304)
        txt = resp.read().decode('ascii')
        self.assertEqual(txt, '')
        os.utime("test/testfile.txt", None)
        conn.request('GET', '/test/testfile.txt',
            headers={'If-Modified-Since': lm})
        resp = conn.getresponse()
        lm1 = resp.headers['Last-Modified']
        txt = resp.read().decode('ascii')
        self.assertEqual(txt, 'test\nfile\n')

        self.assertNotEqual(lm, lm1)