github.com/abayer/test-infra@v0.0.5/queue_health/graph/graph_test.py (about) 1 #!/usr/bin/env python 2 3 # Copyright 2016 The Kubernetes Authors. 4 # 5 # Licensed under the Apache License, Version 2.0 (the "License"); 6 # you may not use this file except in compliance with the License. 7 # You may obtain a copy of the License at 8 # 9 # http://www.apache.org/licenses/LICENSE-2.0 10 # 11 # Unless required by applicable law or agreed to in writing, software 12 # distributed under the License is distributed on an "AS IS" BASIS, 13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 # See the License for the specific language governing permissions and 15 # limitations under the License. 16 17 """Tests for graph.""" 18 19 import datetime 20 import unittest 21 22 import graph 23 24 25 class GraphTest(unittest.TestCase): 26 def test_parse_line_normal(self): 27 res = graph.parse_line( 28 '2017-02-28', '13:50:12.555', 'True', '50', '8', '17', 'False', 7) 29 expected = ( 30 datetime.datetime(2017, 2, 28, 13, 50, 12, 555000), 31 True, 32 50, 8, 17, False, 7) 33 self.assertEquals(res, expected) 34 35 def test_parse_line_fractionless(self): 36 res = graph.parse_line( 37 '2017-02-28', '13:50:12', 'True', '50', '8', '17', 'False', 7) 38 expected = ( 39 datetime.datetime(2017, 2, 28, 13, 50, 12, 0), 40 True, 41 50, 8, 17, False, 7) 42 self.assertEquals(res, expected) 43 44 def test_parse_line_mergeless(self): 45 res = graph.parse_line( 46 '2017-02-28', '13:50:12.555', 'True', '50', '8', '17', 'False') 47 expected = ( 48 datetime.datetime(2017, 2, 28, 13, 50, 12, 555000), 49 True, 50 50, 8, 17, False, 0) 51 self.assertEquals(res, expected) 52 53 54 55 if __name__ == '__main__': 56 unittest.main()