def test_location_sequence(): with open(os.path.join(os.path.dirname(__file__),'fixtures','location_sequence.yaml')) as fixtures_file: fixtures=yaml.load(fixtures_file) trial_graph = Greengraph(start,end) for fixture in fixtures: steps = fixture.pop('steps') expected = np.asarray(fixture.pop('answer')) answer = trial_graph.location_sequence(fixture.pop('start'),fixture.pop('end'),steps) # cannot assert_equal on arrays, instead loop over elements for step in range(steps): for coord in range(2): assert_equal(expected[step,coord],answer[step,coord])
def test_location_sequence(): # Test that the location_sequence method computes the steps between two # coordinates correctly test_Greengraph = Greengraph(start, end) with open(os.path.join(os.path.dirname(__file__), "fixtures", "location_sequence.yaml")) as fixtures_file: fixtures = yaml.load(fixtures_file) for fixture in fixtures: expected_results = fixture.pop("result") i = 0 test_sequence = test_Greengraph.location_sequence( (fixture.pop("startlat"), fixture.pop("startlon")), (fixture.pop("endlat"), fixture.pop("endlon")), fixture.pop("steps")) for result in expected_results: assert_equal(test_sequence[i][0], result) assert_equal(test_sequence[i][1], result) i += 1