Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

#!/usr/bin/env python 

# -*- coding: utf-8 -*- 

""" 

The libgse1 test suite. 

""" 

 

from obspy.gse2 import libgse1 

from obspy.gse2.libgse2 import ChksumError 

import os 

import unittest 

 

 

class LibGSE1TestCase(unittest.TestCase): 

    """ 

    Test cases for libgse1. 

    """ 

    def setUp(self): 

        # directory where the test files are located 

        self.path = os.path.join(os.path.dirname(__file__), 'data') 

 

    def test_verifyChecksums(self): 

        """ 

        Tests verifying checksums for CM6 encoded GSE1 files. 

        """ 

        #1 

        fh = open(os.path.join(self.path, 'acc.gse'), 'rb') 

        libgse1.read(fh, verify_chksum=True) 

        fh.close() 

        #2 

        fh = open(os.path.join(self.path, 'y2000.gse'), 'rb') 

        libgse1.read(fh, verify_chksum=True) 

        fh.close() 

        #3 

        fh = open(os.path.join(self.path, 'loc_STAU20031119011659.z'), 'rb') 

        libgse1.read(fh, verify_chksum=True) 

        fh.close() 

        #4 - second checksum is wrong 

        fh = open(os.path.join(self.path, 'GRF_031102_0225.GSE.wrong_chksum'), 

                  'rb') 

        libgse1.read(fh, verify_chksum=True)  # correct 

        self.assertRaises(ChksumError, libgse1.read, fh, verify_chksum=True) 

        fh.close() 

 

 

def suite(): 

    return unittest.makeSuite(LibGSE1TestCase, 'test') 

 

 

if __name__ == '__main__': 

    unittest.main(defaultTest='suite')