Beispiel #1
0
 def test_last_bridge(self):
     bridge_copy = copy.deepcopy(BRIDGE_FORMATTED_BACK_UP)
     bf.inspect_bridges(bridge_copy, [2781], "10/23/2018", 12.20)
     expect = True
     actual = bf.get_bridge(
         bridge_copy,
         2781)[bf.LAST_INSPECTED_INDEX] == "10/23/2018" and bf.get_bridge(
             bridge_copy, 2781)[bf.BCIS_INDEX][0] == 12.20
     self.assertEqual(expect, actual)
Beispiel #2
0
 def test_all_bridges_2212(self):
     expect = fb.all_bridges_2212
     actual = []
     for i in range(1, 2782):
         actual.append(
             bf.get_distance_between(
                 bf.get_bridge(BRIDGE_FORMATTED_BACK_UP, i),
                 bf.get_bridge(BRIDGE_FORMATTED_BACK_UP, 2212)))
     self.assertListEqual(expect, actual)
Beispiel #3
0
 def test_last_fifty(self):
     expect = fb.last_fifty_distance
     actual = []
     for i in range(2731, 2781):
         actual.append(
             bf.get_distance_between(
                 bf.get_bridge(BRIDGE_FORMATTED_BACK_UP, i),
                 bf.get_bridge(BRIDGE_FORMATTED_BACK_UP, i + 1)))
     self.assertListEqual(expect, actual)
Beispiel #4
0
 def test_bridge_random_two_id(self):
     expect = 917
     first_list = bf.get_bridge(BRIDGE_FORMATTED_BACK_UP, 917)
     second_list = bf.get_bridge(BRIDGE_FORMATTED_BACK_UP, 3)
     test_list = []
     test_list.append(first_list)
     test_list.append(second_list)
     actual = bf.find_closest_bridge(test_list, 3)
     self.assertEqual(
         expect, actual,
         "There are randomly two list in the list no matted how far away you have to return the id beside 3"
     )
Beispiel #5
0
 def test_last_fifty_random_three(self):
     ids = random.sample(range(2732, 2781), 3)
     bridge_copy = copy.deepcopy(BRIDGE_FORMATTED_BACK_UP)
     bf.inspect_bridges(bridge_copy, ids, "10/23/2018", 12.20)
     expect = 3
     acc = 0
     for bridge_id in range(2732, 2781):
         if (bf.get_bridge(bridge_copy, bridge_id)[bf.LAST_INSPECTED_INDEX]
                 == "10/23/2018" and bf.get_bridge(
                     bridge_copy, bridge_id)[bf.BCIS_INDEX][0] == 12.20
                 and bridge_id in ids):
             acc += 1
     self.assertEqual(expect, acc)
Beispiel #6
0
 def test_all_even_bridges(self):
     ids = []
     for i in range(2, 2782, 2):
         ids.append(i)
     bridge_copy = copy.deepcopy(BRIDGE_FORMATTED_BACK_UP)
     bf.inspect_bridges(bridge_copy, ids, "10/23/2018", 12.20)
     expect = 1390
     acc = 0
     for bridge_id in range(1, 2782):
         if (bf.get_bridge(bridge_copy, bridge_id)[bf.LAST_INSPECTED_INDEX]
                 == "10/23/2018" and bf.get_bridge(
                     bridge_copy, bridge_id)[bf.BCIS_INDEX][0] == 12.20
                 and bridge_id % 2 == 0):
             acc += 1
     self.assertEqual(expect, acc)
Beispiel #7
0
 def test_first_fifty(self):
     expect = BRIDGE_FORMATTED_BACK_UP[0:50]
     actual = []
     for i in range(1, 51):
         actual.append(bf.get_bridge(BRIDGE_FORMATTED_BACK_UP, i))
     self.assertListEqual(expect, actual,
                          "This test the list of first fifty bridges")
Beispiel #8
0
 def test_first(self):
     expect = fb.first_fifty[0]
     actual = bf.get_bridge(BRIDGE_FORMATTED_BACK_UP, 1)
     self.assertEqual(
         expect, actual,
         "You should return the bridge of id 1, this is your doctest, if you did not pass please also check the rest of your doctest"
     )
Beispiel #9
0
 def test_last_fifty(self):
     expect = BRIDGE_FORMATTED_BACK_UP[2732:]
     actual = []
     for i in range(2733, 2782):
         actual.append(bf.get_bridge(BRIDGE_FORMATTED_BACK_UP, i))
     self.assertListEqual(expect, actual,
                          "This test the list of last fifty bridges")
Beispiel #10
0
 def test_all_bridges(self):
     expect = BRIDGE_FORMATTED_BACK_UP
     actual = []
     for i in range(1, 2782):
         actual.append(bf.get_bridge(BRIDGE_FORMATTED_BACK_UP, i))
     self.assertListEqual(
         expect, actual,
         "This test the list of whole bridges in the given data")
Beispiel #11
0
 def test_last_fifty_random_three(self):
     ids = random.sample(range(2732, 2782), 3)
     bridge_copy = copy.deepcopy(BRIDGE_FORMATTED_BACK_UP)
     for bridge_id in ids:
         bf.add_rehab(bridge_copy, bridge_id, "12/20/2018", False)
     expect = 3
     acc = 0
     for i in range(2732, 2782):
         bridge = bf.get_bridge(bridge_copy, i)
         if bridge[bf.LAST_MINOR_INDEX] == "12/20/2018" and i in ids:
             acc += 1
     self.assertEqual(expect, acc)
Beispiel #12
0
                  [
                      3, 'STOKES RIVER BRIDGE', '6', 45.036739, -81.33579,
                      '1958', '2013', '', 1, [16.0], 18.4, '08/28/2013',
                      [85.1, 67.8, 67.4, 69.2, 70.0, 70.5, 75.1, 90.1]
                  ]]

# Type checks and simple checks for bridge_functions module

# Type and simple check bridge_functions.get_bridge
our_print('Checking get_bridge...')
sample = [inner[:] for inner in sample_bridges]
for lst in sample:
    lst[9] = lst[9][:]
    lst[12] = lst[12][:]

result = bf.get_bridge(sample, 1)
assert isinstance(result, list), \
    '''bridge_functions.get_bridge should return a list'''
assert len(result) == 13, \
    '''bridge_functions.get_bridge should return a list of length 13'''
assert isinstance(result[0], int), \
    '''the first value in the list returned by bridge_functions.get_bridge should be a int'''
assert isinstance(result[1], str), \
    '''the second value in the list returned by bridge_functions.get_bridge should be an str'''
assert isinstance(result[2], str), \
    '''the third value in the list returned by bridge_functions.get_bridge should be an str'''
assert isinstance(result[3], float), \
    '''the fourth value in the list returned by bridge_functions.get_bridge should be an float'''
assert isinstance(result[4], float), \
    '''the fifth value in the list returned by bridge_functions.get_bridge should be an float'''
assert isinstance(result[5], str), \
Beispiel #13
0
 def test_last(self):
     expect = fb.last_fifty[-1]
     actual = bf.get_bridge(BRIDGE_FORMATTED_BACK_UP, 2781)
     self.assertEqual(expect, actual, "You should return the last bridge")
Beispiel #14
0
 def test_middle_of_last_fifty(self):
     expect = fb.last_fifty[24]
     actual = bf.get_bridge(BRIDGE_FORMATTED_BACK_UP, 2756)
     self.assertEqual(expect, actual,
                      "You should return the bridge of id 2756")
Beispiel #15
0
 def test_invalid_case_2(self):
     expect = []
     actual = bf.get_bridge(BRIDGE_FORMATTED_BACK_UP, 2900)
     self.assertEqual(
         expect, actual,
         "This gives an id out of bridges you should return an empty list")
Beispiel #16
0
 def tes_invalid_case_1(self):
     expect = []
     actual = bf.get_bridge(BRIDGE_FORAMTTED_BACK_UP[1:50], 0)
     self.assertEqual(
         expect, actual,
         "This is an invlaid id you should return an empty list")