def test_large_file(self): """Test previewing a large file.""" with open(self.tempfile.name, 'w') as f: f.write('a' * (main.MAX_PREVIEW_LOG_BYTE_COUNT + 10)) self.assertIn('a' * main.MAX_PREVIEW_LOG_BYTE_COUNT, main.read_logs(self.tempfile.name)) self.assertNotIn('a' * (main.MAX_PREVIEW_LOG_BYTE_COUNT + 1), main.read_logs(self.tempfile.name))
def test_file_not_exist(self): """Test file not exist.""" self.another_tempfile = tempfile.NamedTemporaryFile(delete=True) self.another_tempfile.close() self.assertEqual( "%s doesn't exist." % self.another_tempfile.name, main.read_logs(self.another_tempfile.name))
def test_small_file(self): """Test small file.""" with open(self.tempfile.name, 'w') as f: f.write('some logs') self.assertIn('some logs', main.read_logs(self.tempfile.name))