def test_solve_for_unfound_user(aocd_dir, mocker): input_path = aocd_dir / "thetesttoken" / "2018_01_input.txt" input_path.write_text("someinput") other_plug = mocker.Mock() other_plug.name = "otherplugin" mocker.patch("pkg_resources.iter_entry_points", return_value=iter([other_plug])) puzzle = Puzzle(year=2018, day=1) with pytest.raises(AocdError("No entry point found for 'myplugin'")): puzzle.solve_for("myplugin") other_plug.load.assert_not_called() other_plug.load.return_value.assert_not_called()
def test_solve_for(aocd_dir, mocker): input_path = aocd_dir / "thetesttoken" / "2018_01_input.txt" input_path.write_text("blah") plug1 = mocker.Mock() plug1.name = "myplugin" plug2 = mocker.Mock() plug2.name = "otherplugin" mocker.patch("pkg_resources.iter_entry_points", return_value=iter([plug2, plug1])) puzzle = Puzzle(year=2018, day=1) puzzle.solve_for("myplugin") plug1.load.assert_called_once_with() plug1.load.return_value.assert_called_once_with(year=2018, day=1, data="blah") plug2.load.assert_not_called() plug2.load.return_value.assert_not_called()