test_gnsstk_timeconvert.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 from cStringIO import StringIO
4 import sys
5 import unittest
6 import gnsstk_timeconvert
7 
8 
9 default_condition = lambda expected,actual: expected.split() == actual.split()
10 
11 
12 def run_test(test, commands, expected='', pass_condition=default_condition, raises=None):
13  if raises is None:
14  old_stdout = sys.stdout
15  sys.stdout = mystdout = StringIO()
16  gnsstk_timeconvert.main(commands)
17  actual = mystdout.getvalue()
18  sys.stdout = old_stdout
19  fail_message = '\nExpected ouput: \n' + expected + "Actual output: " + actual
20  test.assertTrue(pass_condition(expected, actual), fail_message)
21  else:
22  test.assertRaises(raises, gnsstk_timeconvert.main, commands)
23 
24 
25 class ANSI_input(unittest.TestCase):
26  def test(self):
27  run_test(self, ['-A', '1370983571'],
28  ' Month/Day/Year H:M:S 06/11/2013 20:46:11 GPS\n'
29  ' Modified Julian Date 56454.865405093 GPS\n'
30  ' GPSweek DayOfWeek SecOfWeek 720 2 247571.000000\n'
31  ' FullGPSweek Zcount 1744 165047\n'
32  ' Year DayOfYear SecondOfDay 2013 162 74771.000000\n'
33  ' Unix: Second Microsecond 1370983571 0\n'
34  ' Zcount: 29-bit (32-bit) 377652407 (914523319)\n')
35 
36 
37 class civil_input(unittest.TestCase):
38  def test(self):
39  run_test(self, ['-c', '5 11 2010 6:15:59'],
40  ' Month/Day/Year H:M:S 05/11/2010 06:15:59 GPS\n'
41  ' Modified Julian Date 55327.261099537 GPS\n'
42  ' GPSweek DayOfWeek SecOfWeek 559 2 195359.000000\n'
43  ' FullGPSweek Zcount 1583 130239\n'
44  ' Year DayOfYear SecondOfDay 2010 131 22559.000000\n'
45  ' Unix: Second Microsecond 1273558559 0\n'
46  ' Zcount: 29-bit (32-bit) 293207231 (830078143)\n')
47 
48 
49 class RINEX_input(unittest.TestCase):
50  def test(self):
51  run_test(self, ['-R', '05 06 1985 13:50:02'],
52  ' Month/Day/Year H:M:S 11/06/2010 13:00:00 GPS\n'
53  ' Modified Julian Date 55506.541666667 GPS\n'
54  ' GPSweek DayOfWeek SecOfWeek 584 6 565200.000000\n'
55  ' FullGPSweek Zcount 1608 376800\n'
56  ' Year DayOfYear SecondOfDay 2010 310 46800.000000\n'
57  ' Unix: Second Microsecond 1289048400 0\n'
58  ' Zcount: 29-bit (32-bit) 306560992 (843431904)\n')
59 
60 
61 class ws_input(unittest.TestCase):
62  def test(self):
63  run_test(self, ['-f', '158 200'],
64  ' Month/Day/Year H:M:S 01/16/1983 00:03:20 GPS\n'
65  ' Modified Julian Date 45350.002314815 GPS\n'
66  ' GPSweek DayOfWeek SecOfWeek 158 0 200.000000\n'
67  ' FullGPSweek Zcount 158 133\n'
68  ' Year DayOfYear SecondOfDay 1983 016 200.000000\n'
69  ' Unix: Second Microsecond 411523400 0\n'
70  ' Zcount: 29-bit (32-bit) 82837637 (82837637)\n')
71 
72 
73 class ews_input(unittest.TestCase):
74  def test(self):
75  run_test(self, ['-o', '01 1379 500'],
76  ' Month/Day/Year H:M:S 06/11/2006 00:08:20 GPS\n'
77  ' Modified Julian Date 53897.005787037 GPS\n'
78  ' GPSweek DayOfWeek SecOfWeek 355 0 500.000000\n'
79  ' FullGPSweek Zcount 1379 333\n'
80  ' Year DayOfYear SecondOfDay 2006 162 500.000000\n'
81  ' Unix: Second Microsecond 1149984500 0\n'
82  ' Zcount: 29-bit (32-bit) 186122573 (722993485)\n')
83 
84 
85 class ews_input_long(unittest.TestCase):
86  def test(self):
87  run_test(self, ['--ews', '01 1379 500'],
88  ' Month/Day/Year H:M:S 06/11/2006 00:08:20 GPS\n'
89  ' Modified Julian Date 53897.005787037 GPS\n'
90  ' GPSweek DayOfWeek SecOfWeek 355 0 500.000000\n'
91  ' FullGPSweek Zcount 1379 333\n'
92  ' Year DayOfYear SecondOfDay 2006 162 500.000000\n'
93  ' Unix: Second Microsecond 1149984500 0\n'
94  ' Zcount: 29-bit (32-bit) 186122573 (722993485)\n')
95 
96 
97 class ews_input_addsec(unittest.TestCase):
98  def test(self):
99  run_test(self, ['-o 01 1379 500', '-a 7'],
100  ' Month/Day/Year H:M:S 06/11/2006 00:08:27 GPS\n'
101  ' Modified Julian Date 53897.005868056 GPS\n'
102  ' GPSweek DayOfWeek SecOfWeek 355 0 507.000000\n'
103  ' FullGPSweek Zcount 1379 338\n'
104  ' Year DayOfYear SecondOfDay 2006 162 507.000000\n'
105  ' Unix: Second Microsecond 1149984507 0\n'
106  ' Zcount: 29-bit (32-bit) 186122578 (722993490)\n')
107 
108 
109 class ews_input_subsec(unittest.TestCase):
110  def test(self):
111  run_test(self, ['-o 01 1379 500', '-s 19'],
112  ' Month/Day/Year H:M:S 06/11/2006 00:08:01 GPS\n'
113  ' Modified Julian Date 53897.005567130 GPS\n'
114  ' GPSweek DayOfWeek SecOfWeek 355 0 481.000000\n'
115  ' FullGPSweek Zcount 1379 320\n'
116  ' Year DayOfYear SecondOfDay 2006 162 481.000000\n'
117  ' Unix: Second Microsecond 1149984481 0\n'
118  ' Zcount: 29-bit (32-bit) 186122560 (722993472)\n')
119 
120 
121 class ews_input_addsubsec(unittest.TestCase):
122  def test(self):
123  run_test(self, ['-o 01 1379 500', '-a', '1', '2', '-s', '5', '6'],
124  ' Month/Day/Year H:M:S 06/11/2006 00:08:12 GPS\n'
125  ' Modified Julian Date 53897.005694444 GPS\n'
126  ' GPSweek DayOfWeek SecOfWeek 355 0 492.000000\n'
127  ' FullGPSweek Zcount 1379 328\n'
128  ' Year DayOfYear SecondOfDay 2006 162 492.000000\n'
129  ' Unix: Second Microsecond 1149984492 0\n'
130  ' Zcount: 29-bit (32-bit) 186122568 (722993480)\n')
131 
132 
133 class julian_input(unittest.TestCase):
134  def test(self):
135  run_test(self, ['-j', '2456455.361628'],
136  ' Month/Day/Year H:M:S 06/11/2013 20:40:44 GPS\n'
137  ' Modified Julian Date 56454.861628000 GPS\n'
138  ' GPSweek DayOfWeek SecOfWeek 720 2 247244.659200\n'
139  ' FullGPSweek Zcount 1744 164829\n'
140  ' Year DayOfYear SecondOfDay 2013 162 74444.659200\n'
141  ' Unix: Second Microsecond 1370983244 659200\n'
142  ' Zcount: 29-bit (32-bit) 377652189 (914523101)\n')
143 
144 
145 class mjd_input(unittest.TestCase):
146  def test(self):
147  run_test(self, ['-m', '56454.857905304'],
148  ' Month/Day/Year H:M:S 06/11/2013 20:35:23 GPS\n'
149  ' Modified Julian Date 56454.857905304 GPS\n'
150  ' GPSweek DayOfWeek SecOfWeek 720 2 246923.018266\n'
151  ' FullGPSweek Zcount 1744 164615\n'
152  ' Year DayOfYear SecondOfDay 2013 162 74123.018266\n'
153  ' Unix: Second Microsecond 1370982923 18266\n'
154  ' Zcount: 29-bit (32-bit) 377651975 (914522887)\n')
155 
156 
157 class unix_input(unittest.TestCase):
158  def test(self):
159  run_test(self, ['-u 1470956546'],
160  ' Month/Day/Year H:M:S 08/11/2016 23:02:26 GPS\n'
161  ' Modified Julian Date 57611.960023148 GPS\n'
162  ' GPSweek DayOfWeek SecOfWeek 885 4 428546.000000\n'
163  ' FullGPSweek Zcount 1909 285697\n'
164  ' Year DayOfYear SecondOfDay 2016 224 82946.000000\n'
165  ' Unix: Second Microsecond 1470956546 0\n'
166  ' Zcount: 29-bit (32-bit) 464280577 (1001151489)\n')
167 
168 
169 class unix_input_long(unittest.TestCase):
170  def test(self):
171  run_test(self, ['--unixtime', '1470956546'],
172  ' Month/Day/Year H:M:S 08/11/2016 23:02:26 GPS\n'
173  ' Modified Julian Date 57611.960023148 GPS\n'
174  ' GPSweek DayOfWeek SecOfWeek 885 4 428546.000000\n'
175  ' FullGPSweek Zcount 1909 285697\n'
176  ' Year DayOfYear SecondOfDay 2016 224 82946.000000\n'
177  ' Unix: Second Microsecond 1470956546 0\n'
178  ' Zcount: 29-bit (32-bit) 464280577 (1001151489)\n')
179 
180 
181 class zcount_input(unittest.TestCase):
182  def test(self):
183  run_test(self, ['-Z 1570956546'],
184  ' Month/Day/Year H:M:S 06/10/2037 07:02:27 GPS\n'
185  ' Modified Julian Date 65219.293368056 GPS\n'
186  ' GPSweek DayOfWeek SecOfWeek 948 3 284547.000000\n'
187  ' FullGPSweek Zcount 2996 189698\n'
188  ' Year DayOfYear SecondOfDay 2037 161 25347.000000\n'
189  ' Unix: Second Microsecond 2128230147 0\n'
190  ' Zcount: 29-bit (32-bit) 497214722 (1570956546)\n')
191 
192 
193 class doy_input(unittest.TestCase):
194  def test(self):
195  run_test(self, ['-y 1994 24 10000'],
196  ' Month/Day/Year H:M:S 01/24/1994 02:46:40 GPS\n'
197  ' Modified Julian Date 49376.115740741 GPS\n'
198  ' GPSweek DayOfWeek SecOfWeek 733 1 96400.000000\n'
199  ' FullGPSweek Zcount 733 64266\n'
200  ' Year DayOfYear SecondOfDay 1994 024 10000.000000\n'
201  ' Unix: Second Microsecond 759379600 0\n'
202  ' Zcount: 29-bit (32-bit) 384367370 (384367370)\n')
203 
204 
205 class wz_input_before_epoch(unittest.TestCase):
206  def test(self):
207  run_test(self, ['-w 1023 604799'],
208  ' Month/Day/Year H:M:S 01/16/1980 11:59:58 GPS\n'
209  ' Modified Julian Date 44254.499982639 GPS\n'
210  ' GPSweek DayOfWeek SecOfWeek 1 3 302398.500000\n'
211  ' FullGPSweek Zcount 1 201599\n'
212  ' Year DayOfYear SecondOfDay 1980 016 43198.500000\n'
213  ' Unix: Second Microsecond 316871998 500000\n'
214  ' Zcount: 29-bit (32-bit) 725887 (725887)\n')
215 
216 
217 class formatted_ouput(unittest.TestCase):
218  def test(self):
219  run_test(self, ['-R', '05 06 1985 13:50:02', '-F', 'ms:%K, year:%Y'],
220  'ms:1289048400, year:2010')
221 
222 def main():
223  unittest.main()
224 
225 if __name__ == '__main__':
226  main()
test_gnsstk_timeconvert.unix_input_long.test
def test(self)
Definition: test_gnsstk_timeconvert.py:170
test_gnsstk_timeconvert.formatted_ouput.test
def test(self)
Definition: test_gnsstk_timeconvert.py:218
test_gnsstk_timeconvert.RINEX_input
Definition: test_gnsstk_timeconvert.py:49
test_gnsstk_timeconvert.ews_input_addsubsec.test
def test(self)
Definition: test_gnsstk_timeconvert.py:122
test_gnsstk_timeconvert.ews_input.test
def test(self)
Definition: test_gnsstk_timeconvert.py:74
test_gnsstk_timeconvert.formatted_ouput
Definition: test_gnsstk_timeconvert.py:217
test_gnsstk_timeconvert.RINEX_input.test
def test(self)
Definition: test_gnsstk_timeconvert.py:50
test_gnsstk_timeconvert.doy_input.test
def test(self)
Definition: test_gnsstk_timeconvert.py:194
test_gnsstk_timeconvert.main
def main()
Definition: test_gnsstk_timeconvert.py:222
test_gnsstk_timeconvert.ANSI_input
Definition: test_gnsstk_timeconvert.py:25
test_gnsstk_timeconvert.mjd_input.test
def test(self)
Definition: test_gnsstk_timeconvert.py:146
test_gnsstk_timeconvert.zcount_input
Definition: test_gnsstk_timeconvert.py:181
test_gnsstk_timeconvert.julian_input
Definition: test_gnsstk_timeconvert.py:133
test_gnsstk_timeconvert.ews_input_long
Definition: test_gnsstk_timeconvert.py:85
test_gnsstk_timeconvert.ews_input_long.test
def test(self)
Definition: test_gnsstk_timeconvert.py:86
test_gnsstk_timeconvert.ews_input
Definition: test_gnsstk_timeconvert.py:73
test_gnsstk_timeconvert.unix_input_long
Definition: test_gnsstk_timeconvert.py:169
test_gnsstk_timeconvert.wz_input_before_epoch.test
def test(self)
Definition: test_gnsstk_timeconvert.py:206
test_gnsstk_timeconvert.ews_input_addsec
Definition: test_gnsstk_timeconvert.py:97
test_gnsstk_timeconvert.ws_input.test
def test(self)
Definition: test_gnsstk_timeconvert.py:62
test_gnsstk_timeconvert.julian_input.test
def test(self)
Definition: test_gnsstk_timeconvert.py:134
test_gnsstk_timeconvert.run_test
def run_test(test, commands, expected='', pass_condition=default_condition, raises=None)
Definition: test_gnsstk_timeconvert.py:12
test_gnsstk_timeconvert.ws_input
Definition: test_gnsstk_timeconvert.py:61
test_gnsstk_timeconvert.unix_input.test
def test(self)
Definition: test_gnsstk_timeconvert.py:158
test_gnsstk_timeconvert.mjd_input
Definition: test_gnsstk_timeconvert.py:145
test_gnsstk_timeconvert.doy_input
Definition: test_gnsstk_timeconvert.py:193
test_gnsstk_timeconvert.ANSI_input.test
def test(self)
Definition: test_gnsstk_timeconvert.py:26
test_gnsstk_timeconvert.unix_input
Definition: test_gnsstk_timeconvert.py:157
test_gnsstk_timeconvert.zcount_input.test
def test(self)
Definition: test_gnsstk_timeconvert.py:182
test_gnsstk_timeconvert.civil_input
Definition: test_gnsstk_timeconvert.py:37
test_gnsstk_timeconvert.ews_input_addsec.test
def test(self)
Definition: test_gnsstk_timeconvert.py:98
test_gnsstk_timeconvert.ews_input_subsec.test
def test(self)
Definition: test_gnsstk_timeconvert.py:110
test_gnsstk_timeconvert.civil_input.test
def test(self)
Definition: test_gnsstk_timeconvert.py:38
test_gnsstk_timeconvert.ews_input_subsec
Definition: test_gnsstk_timeconvert.py:109
gnsstk_timeconvert.main
def main(args=sys.argv[1:])
Definition: gnsstk_timeconvert.py:48
test_gnsstk_timeconvert.wz_input_before_epoch
Definition: test_gnsstk_timeconvert.py:205
test_gnsstk_timeconvert.ews_input_addsubsec
Definition: test_gnsstk_timeconvert.py:121


gnsstk
Author(s):
autogenerated on Wed Oct 25 2023 02:40:41