# these should test twisted specific code ONLY
from zope.interface import implements

from twisted.internet.interfaces import IMulticastTransport, IUDPTransport
from twisted.trial import unittest

# should these contain src?
from .. import server
from .. import utils 
from .. import client

class FakeUdpTransport(object):
    """ Instead of connecting through the network, this transport 
    writes the broadcast messages to a variable that can be 
    checked. """

    implements(IUDPTransport)

    def __init__(self):
        self.msgs = []

    def write(self, packet, addr=None):
        self.msgs.append(repr(packet))

    def connect(host, port):
        pass

    def getHost():
        pass

    def stopListening():
        pass

class BroadcastServerTests(unittest.TestCase):
    def setUp(self):
        self.protocol = server.Broadcaster('1.1.1.1')
        self.tr = FakeUdpTransport()
        self.protocol.transport = self.tr
        
    def test_broadcast(self):
        self.protocol.sendHeartbeat()
        self.assertTrue(len(self.tr.msgs) > 0)
        self.assertTrue(self.tr.msgs[0] == "'1.1.1.1:8888'")

class ClientTests(unittest.TestCase):
    pass
        

class FileServerTests(unittest.TestCase):

    def test_Fileserver(self):
        self.assertTrue(True)

class FileWalkerTests(unittest.TestCase):
   
    def test_list_files(self):
        f = utils.list_files()
        # make dirs in temp
        self.assertTrue(True)
        # check they exist
        # clean them up

    def test_creates_json():
        pass

@@ -1,50 +1,28 @@
-# these should test twisted specific code ONLY
+import os%0Aimport shutil%0A
 %0Afro
@@ -1257,19 +1257,20 @@
 ertTrue(
-Tru
+Fals
 e)%0A%0Aclas
@@ -1275,18 +1275,13 @@
 ass 
-FileWalker
+Utils
 Test
@@ -1305,16 +1305,17 @@
 se):%0A   
+ 
 %0A    def
@@ -1319,61 +1319,352 @@
 def 
-test_list_files(self):%0A        f = utils.
+setUp(self):%0A        self.home = %22./%22 # use the tests directory%0A        self.test_dir = %22./test_dir%22%0A        self.test_file= %22./test_dir/test_file%22%0A        os.chdir(self.home)%0A        os.mkdir(self.test_dir)%0A        open(self.test_file, 'w').close()%0A%0A    def tearDown(self):%0A        shutil.rmtree(self.test_dir)%0A%0A    def test_
 list
+s
 _files(
-)
+self):
 %0A   
@@ -1672,148 +1672,259 @@
     
-# make dirs in temp%0A        self.assertTrue(True)%0A        # check they exist%0A        # clean them up%0A%0A    def test_creates_json():%0A        pass
+results = utils._list_files(self.test_dir)%0A        self.assertTrue(results%5B0%5D == self.test_file)%0A%0A    def test_lists_dirs(self):%0A        results = utils._list_dirs(self.test_dir)%0A        self.assertTrue(results%5B0%5D == self.test_dir)%0A%0A%0A%0A        %0A        %0A%0A
 %0A

add test for _list operations