def test_run_constant_predictor(self):
     """ Tests the input and output formats of run()"""
     reader = StringIO("1:\n1\n2\n3\n")
     writer = StringIO()
     predictor = ConstantPredictor(1)
     answer = ConstantPredictor(2)
     Netflix.run(reader, writer, predictor, answer)
     self.assertEqual(writer.getvalue(), "1:\n1.0\n1.0\n1.0\nRMSE: 1.00\n")
    def test_run_math_predictor(self):
        """ Tests run() using the MathPredictor """
        reader = StringIO("1:\n1\n2\n3\n")
        writer = StringIO()
        predictor = Netflix.MathPredictor(
            {1: 2.5}, {1: 1.0}, {1: 0, 2: 1, 3: -1})
        answer = ConstantPredictor(3)

        Netflix.run(reader, writer, predictor, answer)
        self.assertEqual(writer.getvalue(), "1:\n2.5\n3.5\n1.5\nRMSE: 0.96\n")