Example #1
0
 def test_example_for_doctest(self):
     expect = 70.88571428571429
     actual = bf.get_average_bci(BRIDGE_FORMATTED_BACK_UP, 1)
     self.assertAlmostEqual(
         expect, actual,
         "This is the example for your doctest, if you did not pass please also check the rest of your doctest"
     )
Example #2
0
 def test_first_fifty(self):
     expect = fb.first_fifty_average
     actual = []
     for i in range(1, 52):
         actual.append(bf.get_average_bci(BRIDGE_FORMATTED_BACK_UP, i))
     self.assertListEqual(
         expect, actual,
         "This test the list of average bci you have from id 1 to 50")
Example #3
0
 def test_last_fifty(self):
     expect = fb.last_fifty_average
     actual = []
     for i in range(2732, 2782):
         actual.append(bf.get_average_bci(BRIDGE_FORMATTED_BACK_UP, i))
     self.assertListEqual(
         expect, actual,
         "This test the list of average bci you have from id2732 to id 2781"
     )
Example #4
0
 def test_middle_fifty(self):
     expect = fb.middle_fifty_average
     actual = []
     for i in range(950, 1002):
         actual.append(bf.get_average_bci(BRIDGE_FORMATTED_BACK_UP, i))
     self.assertListEqual(
         expect, actual,
         "This test the list of average bci you have from id 950 to id 1001"
     )
Example #5
0
assert isinstance(result[10], float), \
    '''the eleventh value in the list returned by bridge_functions.get_bridge should be a float'''
assert isinstance(result[11], str), \
    '''the twelfth value in the list returned by bridge_functions.get_bridge should be an str'''
assert isinstance(result[12], list), \
    '''the thirteenth value in the list returned by bridge_functions.get_bridge should be an list'''
our_print('  check complete')

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

result = bf.get_average_bci(sample, 1)
assert isinstance(result, float), \
    '''bridge_functions.get_average_bci should return a float'''
our_print('  check complete')

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

result = bf.get_total_length_on_highway(sample, '403')
assert isinstance(result, float), \
    '''bridge_functions.get_total_length_on_highway should return a float'''
our_print('  check complete')
Example #6
0
 def test_id_607(self):
     expect = 0.0
     actual = bf.get_average_bci(BRIDGE_FORMATTED_BACK_UP, 607)
     self.assertEqual(expect, actual,
                      "This is only bridge which has 0.0 bci")
Example #7
0
 def test_invalid_case_2(self):
     expect = 0.0
     actual = bf.get_average_bci(BRIDGE_FORMATTED_BACK_UP, 2999)
     self.assertEqual(expect, actual,
                      "This is an invalid id, you should return 0.0")