示例#1
0
class CFDPPutTest(unittest.TestCase):
    def setUp(self):
        # Set up a CFDP entity with ID 1
        self.cfdp = CFDP('1')
        # Patch outgoing path with testdata path
        self.cfdp._data_paths['outgoing'] = os.path.join(
            os.path.dirname(__file__), 'testdata')

    def tearDown(self):
        self.cfdp.disconnect()
        self.cfdp = None

    def test_put(self):
        destination_id = '2'
        source_file = 'small.txt'
        destination_file = 'small.txt'

        transaction_id = self.cfdp.put(destination_id, source_file,
                                       destination_file)

        self.assertEqual(len(self.cfdp._machines), 1,
                         'New machine is created after put request')

        machine = self.cfdp._machines[transaction_id]
        self.assertTrue(isinstance(machine, Sender1),
                        'Entity type is Sender 1 (UNACK, unreliable)')