1 | #!/usr/bin/env python |
---|
2 | # -*- coding: utf-8 -*- |
---|
3 | |
---|
4 | import os |
---|
5 | import sys |
---|
6 | import pytest |
---|
7 | |
---|
8 | sys.path.append('../python') |
---|
9 | from classes.UioFiles import UioFiles |
---|
10 | |
---|
11 | |
---|
12 | class TestUioFiles(): |
---|
13 | ''' |
---|
14 | Test class to test the UIOFiles methods. |
---|
15 | ''' |
---|
16 | |
---|
17 | def test_listFiles(self): |
---|
18 | ''' |
---|
19 | @Description: |
---|
20 | Test the listFiles method from class UIOFiles. |
---|
21 | |
---|
22 | @Input: |
---|
23 | self: instance of TestClass |
---|
24 | Class to test the UIOFiles methods. |
---|
25 | |
---|
26 | @Return: |
---|
27 | <nothing> |
---|
28 | ''' |
---|
29 | # set comparison information |
---|
30 | self.testpath = os.path.join(os.path.dirname(__file__), 'TestDir') |
---|
31 | self.expected = ['FCGG__SL.20160410.40429.16424.grb', |
---|
32 | 'FCOG__ML.20160410.40429.16424.grb', |
---|
33 | 'FCSH__ML.20160410.40429.16424.grb', |
---|
34 | 'OG_OROLSM__SL.20160410.40429.16424.grb', |
---|
35 | 'FCOG_acc_SL.20160409.40429.16424.grb', |
---|
36 | 'FCOG__SL.20160410.40429.16424.grb', |
---|
37 | 'FCSH__SL.20160410.40429.16424.grb'] |
---|
38 | |
---|
39 | # Initialise and collect filenames |
---|
40 | files = UioFiles(self.testpath, '*.grb') |
---|
41 | # get the basename to just check for equality of filenames |
---|
42 | filelist = [os.path.basename(f) for f in files.files] |
---|
43 | # comparison of expected filenames against the collected ones |
---|
44 | assert sorted(self.expected) == sorted(filelist) |
---|
45 | |
---|
46 | return |
---|
47 | |
---|