示例#1
0
def test_fucking_json():
    data = get_json()
    london = data['features'][0]
    wellington = data['features'][1]
    athens = data['features'][2]
    wellington_distance = calc_points(london['geometry']['coordinates'],
                                      wellington['geometry']['coordinates'])
    athens_distance = calc_points(london['geometry']['coordinates'],
                                  athens['geometry']['coordinates'])

    assert compare_distance(athens_distance, wellington_distance) == 0
示例#2
0
def test_calc_basic_distance_origin_dest():
    stub_one = ([0.0, 0.0], [3.0, 4.0])
    stub_two = ([0.0, 0.0], [-3.0, 4.0])
    stub_zero_y = ([0.0, 0.0], [-3.0, 0.0])
    stub_zero_x = ([0.0, 0.0], [0.0, 4.0])
    origin, dest = stub_one[0], stub_one[1]
    assert calc_points(origin, dest) == 5.0
    origin, dest = stub_two[0], stub_two[1]
    assert calc_points(origin, dest) == 5.0
    origin, dest = stub_zero_y
    assert calc_points(origin, dest) == 3.0
    origin, dest = stub_zero_x
    assert calc_points(origin, dest) == 4.0
示例#3
0
    def test_part_2(self, duration, comets_points, dancers_points):
        example = {'comet': Specs(14, 10, 127), 'dancer': Specs(16, 11, 162)}

        self.assertEqual({
            'comet': comets_points,
            'dancer': dancers_points
        }, calc_points(duration, example))
示例#4
0
def test_second_is_smallest():
    stub = ([0.0, 0.0], [5.0, 7.0], [3.0, 4.0])
    origin, dest1, dest2 = stub
    assert compare_distance(calc_points(origin, dest1),
                            calc_points(origin, dest2)) == 1
示例#5
0
def test_calc_not_so_basic_distance_origin_dest():
    stub = ([1.0, 2.0], [3.0, 4.0])
    origin, dest = stub
    assert calc_points(
        origin, dest) == sqrt(pow((3.0 - 1.0), 2) + pow((4.0 - 2.0), 2))