message: API: Add lecture route 404 unit tests
  Some of these will fail until the routes are fixed.
  (I.e. at this moment all except for the DELETE one.)
diff: @@ -14,7 +14,7 @@ const testHelper = new TestHelper(BASE_URL);
  /**
  * Provides simple shared setup functionality used by the lecture success (200) unit tests.
  *
  - * @returns A random 'admin' and 'lecture'.
  + * @returns A random 'lecture', its 'course' and a random 'admin'. The 'admin' is also aliased as 'user'.
  */
  async function lectureSuccessTestSetup() {
  const lecture = await FixtureUtils.getRandomLecture();
  @@ -27,6 +27,7 @@ async function lectureSuccessTestSetup() {
  * Provides simple shared setup functionality used by the lecture access denial (403) unit tests.
  *
  * @returns A 'lecture', its 'course' and an 'unauthorizedTeacher' (i.e. a teacher that isn't part of the course).
  + * The 'unauthorizedTeacher' is also aliased as 'user'.
  */
  async function lectureAccessDenialTestSetup() {
  const lecture = await FixtureUtils.getRandomLecture();
  @@ -35,6 +36,17 @@ async function lectureAccessDenialTestSetup() {
  return {lecture, course, unauthorizedTeacher, user: unauthorizedTeacher};
  }
  +/**
  + * Provides simple shared setup functionality used by the lecture not found (404) unit tests.
  + *
  + * @returns Same as lectureSuccessTestSetup, but the lecture id is set to 000000000000000000000000.
  + */
  +async function lectureNotFoundTestSetup() {
  + const setup = await lectureSuccessTestSetup();
  + setup.lecture._id = '000000000000000000000000';
  + return setup;
  +}
  +
  function lectureShouldEqualRes(lecture: ILectureModel, res: any) {
  res.status.should.be.equal(200);
  should.equal(lecture.id, res.body._id, 'Incorrect id.');
  @@ -62,6 +74,11 @@ describe('Lecture', () => {
  const res = await lectureGetTest(await lectureAccessDenialTestSetup());
  res.status.should.be.equal(403);
  });
  +
  + it('should respond with 404 for an invalid lecture id', async () => {
  + const res = await lectureGetTest(await lectureNotFoundTestSetup());
  + res.status.should.be.equal(404);
  + });
  });
  describe(`POST ${BASE_URL}` , () => {
  @@ -81,6 +98,11 @@ describe('Lecture', () => {
  const res = await lecturePostTest(await lectureAccessDenialTestSetup());
  res.status.should.be.equal(403);
  });
  +
  + it('should respond with 404 for an invalid lecture id', async () => {
  + const res = await lecturePostTest(await lectureNotFoundTestSetup());
  + res.status.should.be.equal(404);
  + });
  });
  describe(`PUT ${BASE_URL}` , () => {
  @@ -99,6 +121,11 @@ describe('Lecture', () => {
  const res = await lecturePutTest(await lectureAccessDenialTestSetup());
  res.status.should.be.equal(403);
  });
  +
  + it('should respond with 404 for an invalid lecture id', async () => {
  + const res = await lecturePutTest(await lectureNotFoundTestSetup());
  + res.status.should.be.equal(404);
  + });
  });
  describe(`DELETE ${BASE_URL}` , () => {
  @@ -117,6 +144,11 @@ describe('Lecture', () => {
  const res = await lectureDeleteTest(await lectureAccessDenialTestSetup());
  res.status.should.be.equal(403);
  });
  +
  + it('should respond with 404 for an invalid lecture id', async () => {
  + const res = await lectureDeleteTest(await lectureNotFoundTestSetup());
  + res.status.should.be.equal(404);
  + });
  });
  });
  