old_contents: from cat.code import GenerateSite
  import unittest
  import json
  import os
  import sys
  import cat.app
  
  def read_json(file):
      with open(file) as fh:
          return json.loads(fh.read())
          #return fh.read()
  
  class TestCat(unittest.TestCase):
      def setUp(self):
          GenerateSite().generate_site()
          self.app = cat.app.catapp.test_client()
  
      def test_main(self):
          rv = self.app.get('/')
          assert rv.status == '200 OK'
          assert b'Presentations from tech events worth watching' in rv.data
  
      def test_404(self):
          rv = self.app.get('/abc')
          #print('Status: ' + rv.status)
          assert rv.status == '200 OK' # TODO really this should be 404 but that gives an error: TypeError: Expected bytes
                      # probably because of the way we pass the values back up in the static_file route
          assert b'Oh. There is no page here.' in rv.data
  
      def test_pages(self):
          rv = self.app.get('/e/ffconf-2009')
          assert rv.status == '200 OK'
          assert b'<h1>Full Frontal - ffconf 2009</h1>' in rv.data
          assert b'<div>Start date: 2009-11-20</div>' in rv.data
          assert b'<div>End date: 2009-11-20</div>' in rv.data
          assert b'https://www.youtube.com/playlist?list' not in rv.data
  
          rv = self.app.get('/e/jsinsa-2016')
          assert rv.status == '200 OK'
          assert b'https://www.youtube.com/playlist?list=PLw7UYp3N0eUaUgeaG3xN4qI4eMojw6u6y' in rv.data
          assert b'<a href="/l/south-africa">' in rv.data
  
  
  #class TestDemo(unittest.TestCase):
  #    def test_generate(self):
  #        GenerateSite().generate_site()
  #        assert True
  #
  #        # This fails on travis, we probably need better reporting to see what is the actual difference
  #        # as I cannot see it. Unless it is only the file_date
  #        files = [
  #            'html/v/yougottalovefrontend-2016/vitaly-friedman-cutting-edge-responsive-web-design.json',
  #            'html/p/zohar-babin.json',
  #        ]
  #        for result_file in files:
  #            expected_file = 'samples/' + os.path.basename(result_file)
  #            #sys.stderr.write(result_file)
  #            #sys.stderr.write("\n")
  #            #sys.stderr.write(expected_file)
  #            #sys.stderr.write("\n")
  #            # read both files
  #            result = read_json(result_file)
  #            expected = read_json(expected_file)
  #            if 'file_date' in expected:
  #                del(expected['file_date'])
  #                del(result['file_date'])
  #            if result != expected:
  #                print("While testing {}\n".format(result_file))
  #                print("Expected: {}".format(expected))
  #                print("Received: {}".format(result))
  #            assert result == expected
  
  # vim: expandtab
  
new_contents: from cat.code import GenerateSite
  import unittest
  import json
  import os
  import sys
  import cat.app
  
  def read_json(file):
      with open(file) as fh:
          return json.loads(fh.read())
          #return fh.read()
  
  class TestCat(unittest.TestCase):
      def setUp(self):
          GenerateSite().generate_site()
          self.app = cat.app.catapp.test_client()
  
      def test_main(self):
          rv = self.app.get('/')
          assert rv.status == '200 OK'
          assert b'Presentations from tech events worth watching' in rv.data
  
      def test_404(self):
          rv = self.app.get('/abc')
          #print('Status: ' + rv.status)
          assert rv.status == '200 OK' # TODO really this should be 404 but that gives an error: TypeError: Expected bytes
                      # probably because of the way we pass the values back up in the static_file route
          assert b'Oh. There is no page here.' in rv.data
  
      def test_pages(self):
          rv = self.app.get('/e/ffconf-2009')
          assert rv.status == '200 OK'
          assert b'<h1>Full Frontal - ffconf 2009</h1>' in rv.data
          assert b'<div>Start date: 2009-11-20</div>' in rv.data
          assert b'<div>End date: 2009-11-20</div>' in rv.data
          assert b'https://www.youtube.com/playlist?list' not in rv.data
  
          rv = self.app.get('/e/jsinsa-2016')
          assert rv.status == '200 OK'
          assert b'https://www.youtube.com/playlist?list=PLw7UYp3N0eUaUgeaG3xN4qI4eMojw6u6y' in rv.data
          assert b'<a href="/l/south-africa">' in rv.data
  
  # vim: expandtab
  
subject: remove old, unused test