def test_formatOutputTakesADictionaryOfTotalIntAndOrderListIntAndReturnsAString(self): test_solution = { 'total': 0, 'order': [0] } actual = format_output(test_solution) assert isinstance(actual, basestring)
def test_formatOutputPutsTheTotalDistanceOnTheTopLine(self): for i in [-1000000, -1, 0, 1, 1000000]: test_solution = { 'total': i, 'order': [3, 0, 1, 2] } expected = '%d\n' % i actual = format_output(test_solution) assert actual.startswith(expected)
def test_formatOutputPutsTheTheNextVertexInOrderOnSubsequentLines(self): for i in range(100): expected = '0\n' test_solution = { 'total': 0, 'order': [] } for j in range(i): rand = random.randrange(-sys.maxint, sys.maxint) test_solution['order'].append(rand) expected = "%s%d\n" % (expected, rand) actual = format_output(test_solution) self.assertEqual(expected, actual)
def run(self): solution = self.algorithm.solve(self.graph) output_string = format_output(solution) FileWriter(self.input_file_name).write_file(output_string)