Exemplo n.º 1
0
    def test_writelines(self):
        from enrol import writelines,readlines
        test_data = ["aaa","bbb","ccc","ddd","eee"]

        result = writelines("testData/write_data", test_data)
        lines = readlines("testData/write_data" )
        self.assertEqual(test_data, lines)
        self.assertEqual(result,1)

        result = writelines("NoSuchDirectory/write_data", ["aaaa"])
        self.assertEqual(result,0)

        '''
Exemplo n.º 2
0
Run this script in the same directory as the enrol module created for the
assignment.
'''


import os, shutil

import enrol

# create test data
if os.path.exists('test_data'):
    shutil.rmtree('test_data')
os.mkdir('test_data')
enrol.writelines(os.path.join('test_data', 'CLASSES'), [
    'bw101.1:bw101:Mon 9.30:2.5.10:Alice Chiswick',
    'bw101.2:bw101:Wed 14.30:2.6.1:Bob Turnham',
    'bw330A:bw330:Tue 15.30:23.5.32:Carlos Stamford'])
enrol.writelines(os.path.join('test_data', 'SUBJECTS'), [
    'bw101:Introductory Basketweaving 1',
    'bw110:Introductory Basketweaving 2',
    'bw330:Underwater Basketweaving'])
enrol.writelines(os.path.join('test_data', 'VENUES'),
    ['2.5.10:18', '2.5.11:18', '2.6.1:22', '23.5.32:50'])
enrol.writelines(os.path.join('test_data', 'bw101.1.roll'),
    ['1124395', '1125622', '1109202', '1136607'])
enrol.writelines(os.path.join('test_data', 'bw330A.roll'),
    ['1125622', '1136607'])

# now test - all assertions should pass
e = enrol.Enrol("test_data")
assert e.subjects() == ['bw101', 'bw110', 'bw330']
Exemplo n.º 3
0
    def setUp(self):
        self.data = 'test-data'

        if os.path.exists(self.data):
            shutil.rmtree(self.data)

        os.mkdir(self.data)

        enrol.writelines(os.path.join(self.data, 'CLASSES'), [
            'bw101.1:bw101:Mon 9.30:2.5.10:Alice Chiswick',
            'bw101.2:bw101:Wed 14.30:2.6.1:Bob Turnham',
            'bw330A:bw330:Tue 15.30:23.5.32:Carlos Stamford'])

        enrol.writelines(os.path.join(self.data, 'SUBJECTS'), [
            'bw101:Introductory Basketweaving 1',
            'bw110:Introductory Basketweaving 2',
            'bw330:Underwater Basketweaving'])

        enrol.writelines(os.path.join(self.data, 'VENUES'),
                   ['2.5.10:18', '2.5.11:18', '2.6.1:22', '23.5.32:50'])

        enrol.writelines(os.path.join(self.data, 'bw101.1.roll'),
                   ['1124395', '1125622', '1109202', '1136607'])

        enrol.writelines(os.path.join(self.data, 'bw101.2.roll'),
                   [])

        enrol.writelines(os.path.join(self.data, 'bw330A.roll'),
                   ['1125622', '1136607'])

        self.e = enrol.Enrol(self.data)