Changeset 76c37a9 in flex_extract.git for Source/Pythontest/TestUIOFiles.py


Ignore:
Timestamp:
Dec 19, 2019, 8:11:12 PM (4 years ago)
Author:
Anne Philipp <anne.philipp@…>
Branches:
master, ctbto, dev
Children:
d720895
Parents:
d2b7217
Message:

updated unit tests to work with updated code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Source/Pythontest/TestUIOFiles.py

    rba99230 r76c37a9  
    55import sys
    66import pytest
     7from mock import patch
    78
    8 sys.path.append('../python')
    9 from classes.UioFiles import UioFiles
     9from . import _config_test
     10sys.path.append('../Python')
     11
     12from Classes.UioFiles import UioFiles
    1013
    1114
    1215class TestUioFiles():
    13     '''
    14     Test class to test the UIOFiles methods.
    15     '''
     16    """Test class to test the UIOFiles methods."""
     17
     18    @classmethod
     19    def setup_class(self):
     20        """Setup status"""
     21        self.testpath = os.path.join(_config_test.PATH_TEST_DIR, 'Dir')
     22        # Initialise and collect filenames
     23        self.files = UioFiles(self.testpath, '*.grb')
    1624
    1725    def test_listFiles(self):
    18         '''
    19         @Description:
    20             Test the listFiles method from class UIOFiles.
     26        """Test the listFiles method from class UIOFiles."""
     27        # set comparison information
     28        self.expected = ['FCGG__SL.20160410.40429.16424.grb',
     29                         'FCOG__ML.20160410.40429.16424.grb',
     30                         'FCSH__ML.20160410.40429.16424.grb',
     31                         'OG_OROLSM__SL.20160410.40429.16424.grb',
     32                         'FCOG_acc_SL.20160409.40429.16424.grb',
     33                         'FCOG__SL.20160410.40429.16424.grb',
     34                         'FCSH__SL.20160410.40429.16424.grb']
    2135
    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')
    4136        # get the basename to just check for equality of filenames
    42         filelist = [os.path.basename(f) for f in files.files]
     37        filelist = [os.path.basename(f) for f in self.files.files]
    4338        # comparison of expected filenames against the collected ones
    4439        assert sorted(self.expected) == sorted(filelist)
    4540
    46         return
    4741
     42    def test_delete_files(self):
     43        """Test if a file is deleted."""
     44        testfile = os.path.join(self.testpath, 'test.test')
     45        open(testfile, 'w').close()
     46        iofile = UioFiles(testfile, 'test.test')
     47        iofile.delete_files()
     48        assert [] == UioFiles(testfile, 'test.test').files
     49
     50
     51    def test_str_(self):
     52        """Test if list of file is correctly converted to string."""
     53        self.expected = "FCSH__SL.20160410.40429.16424.grb, "\
     54                        "FCSH__ML.20160410.40429.16424.grb, "\
     55                        "FCOG__SL.20160410.40429.16424.grb, "\
     56                        "FCOG__ML.20160410.40429.16424.grb, "\
     57                        "OG_OROLSM__SL.20160410.40429.16424.grb, "\
     58                        "FCGG__SL.20160410.40429.16424.grb, "\
     59                        "FCOG_acc_SL.20160409.40429.16424.grb"
     60        assert self.expected == self.files.__str__()
Note: See TracChangeset for help on using the changeset viewer.
hosted by ZAMG