Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-21658

Web services unit tests for external functions and for ws services servers

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: 2.0
    • Fix Version/s: 2.0.1
    • Component/s: Web Services
    • Labels:
      None
    • Difficulty:
      Difficult
    • Affected Branches:
      MOODLE_20_STABLE
    • Fixed Branches:
      MOODLE_20_STABLE

      Description

      We don't have a way to test web services automatically yet. Unit tests would need to be written.

      We need to make difference between two things:

      • test of external functions: external functions mainly are subjected to problems during validation against the ws description. There is also sometime some code around the core functions calls that require testing too.
      • test of web service servers: we would need to emulate a client. Here we want to test the problems coming from the server layer, all communication problem. Specially responses that are most commonly to be a problem.

      Do we need two different unit tests ?

      What is the unit tests status in Moodle 2.0? Are we moving to PHP Unit?

        Gliffy Diagrams

          Activity

          Hide
          dougiamas Martin Dougiamas added a comment -

          Jerome says this is partially done.

          Show
          dougiamas Martin Dougiamas added a comment - Jerome says this is partially done.
          Hide
          jerome Jérôme Mouneyrac added a comment -

          there are some unit tests in /webservice/simpletest/testwebservice.php. The test instructions are in the phpdoc.

          Show
          jerome Jérôme Mouneyrac added a comment - there are some unit tests in /webservice/simpletest/testwebservice.php. The test instructions are in the phpdoc.
          Hide
          jerome Jérôme Mouneyrac added a comment - - edited

          Currently, the existing web service unit tests are for:

          • moodle_group_get_groups (compare the groups total)
          • moodle_user_get_users_by_id (compare the users total)
          • moodle_enrol_get_enrolled_users (compare the enrolled users total for every courses)
          • moodle_course_create_courses (compare values of two created courses)
          • moodle_user_create_users (compare values of two created users)
          • mooodle_course_get_courses (compare the courses total and all the courses values)
          Show
          jerome Jérôme Mouneyrac added a comment - - edited Currently, the existing web service unit tests are for: moodle_group_get_groups (compare the groups total) moodle_user_get_users_by_id (compare the users total) moodle_enrol_get_enrolled_users (compare the enrolled users total for every courses) moodle_course_create_courses (compare values of two created courses) moodle_user_create_users (compare values of two created users) mooodle_course_get_courses (compare the courses total and all the courses values)
          Hide
          jerome Jérôme Mouneyrac added a comment - - edited

          The missing core web service unit tests are:

          all done!

          Show
          jerome Jérôme Mouneyrac added a comment - - edited The missing core web service unit tests are: all done!
          Hide
          jerome Jérôme Mouneyrac added a comment -

          Added:

          • support for PHP soap options in our client (example: SOAP synchronous mode)
          • fix moodle_user_get_users_by_id unit test that compared with deleted users
          • add moodle_user_delete_users unit test
          Show
          jerome Jérôme Mouneyrac added a comment - Added: support for PHP soap options in our client (example: SOAP synchronous mode) fix moodle_user_get_users_by_id unit test that compared with deleted users add moodle_user_delete_users unit test
          Hide
          jerome Jérôme Mouneyrac added a comment - - edited

          Added moodle_user_update_users() (compare two temporary users values, all of the possible values accepted by web services).
          Unit test for users and courses are in CVS.

          Show
          jerome Jérôme Mouneyrac added a comment - - edited Added moodle_user_update_users() (compare two temporary users values, all of the possible values accepted by web services). Unit test for users and courses are in CVS.
          Hide
          jerome Jérôme Mouneyrac added a comment -

          maybe someone should review this unit test file?

          This unit test file can be run on production test, it doesn't do anything till you edit the file.

          These unit tests are calling the real web service functions (purpose of the testing). So some manual setup is needed (you need to create a web service token and to edit it in the unit test code) + some data could potentially be written into the database (you need to manually activate the function test).

          Show
          jerome Jérôme Mouneyrac added a comment - maybe someone should review this unit test file? This unit test file can be run on production test, it doesn't do anything till you edit the file. These unit tests are calling the real web service functions (purpose of the testing). So some manual setup is needed (you need to create a web service token and to edit it in the unit test code) + some data could potentially be written into the database (you need to manually activate the function test).
          Hide
          jerome Jérôme Mouneyrac added a comment -

          added moodle_role_assign and moodle_role_unassign.
          The only externallib.php file left not 100% unit tested is group now...

          Show
          jerome Jérôme Mouneyrac added a comment - added moodle_role_assign and moodle_role_unassign. The only externallib.php file left not 100% unit tested is group now...
          Hide
          jerome Jérôme Mouneyrac added a comment -

          added moodle_get_course_groups and moodle_get_group_members

          Show
          jerome Jérôme Mouneyrac added a comment - added moodle_get_course_groups and moodle_get_group_members
          Hide
          jerome Jérôme Mouneyrac added a comment -

          Ok all done, all passed (SOAP and XMLRPC).

          Even though, there are still lots to be improved. For example we could be extending the unit test class like in backup unit tests (I just discover that, but the fact that we test web service call could not allow it anyway).

          I did some performance testing too, to run all of them:
          xmlrpc: 70s
          soap: 32s

          Show
          jerome Jérôme Mouneyrac added a comment - Ok all done, all passed (SOAP and XMLRPC). Even though, there are still lots to be improved. For example we could be extending the unit test class like in backup unit tests (I just discover that, but the fact that we test web service call could not allow it anyway). I did some performance testing too, to run all of them: xmlrpc: 70s soap: 32s

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                25/Dec/10