Comments

johnstorey’s picture

Title: Tests for Services 3 » Create endpoint
StatusFileSize
new1.44 KB

UPDATE: I made a mistake uploading works in progress. Please scroll down to my patch with full functional endpoint tests and unit tests for services.module. I'll start a new issue for the next file I write unit tests for.

This is the first set of code for the functional endpoint tests. Please note:

  • After an hour of failing to get CVS to give me the tests directory, and get fakeadd to add new directories and files, I have deferred this in favor of uploading a tar file that should be untarred in the 'tests' directory. I know this is an incorrect practice and will get a proper workflow in future changes.
  • As is the code has 3 non-blocking exceptions. The first 2 I have yet to track down, and the 3rd is http://drupal.org/node/944362
  • Typically my test cases do not test for every line of text on a screen, but if desired I will write them to do so for Services
  • These tests rely on the REST Server module being installed.

Apologies for not figuring out how to create a proper patch for this one, but adding directories to a CVS repository seems to be a fairly dark art. I thought it better to get the first revision of the code out and worry about that again for the next patch.

johnstorey’s picture

Status: Active » Needs review
StatusFileSize
new13.71 KB

Added in more test cases and created a proper patch file that will add in the necessary files. This incorporates and supercedes the previous files.

johnstorey’s picture

Title: Create endpoint » Tests for Services 3
StatusFileSize
new14.51 KB

New tests patch file, superceding previous files.

johnstorey’s picture

Title: Create endpoint » Functional Endpoint Tests and Unit Tests for services.module
StatusFileSize
new17.63 KB

I mistepped trying to upload works in progress. Here is my first cut at full functional endpoint tests and unit tests for the services.module.

I will start another issue for unit tests in another file. Putting them all in one issue means I won't have anything to show for months.

Status: Needs review » Needs work

The last submitted patch, 944340-services-module-unit-tests.patch, failed testing.

ygerasimov’s picture

Assigned: johnstorey » Unassigned
Status: Needs work » Needs review
StatusFileSize
new11.85 KB

Here is patch for testing node resource with REST server. See #984426: Testing REST server node resourse. for more details.

kylebrowning’s picture

eeek, ygerasimov, I already did this for Node Endpoint testing. Its in the dev branches for 6.x and 7.x already.

ygerasimov’s picture

StatusFileSize
new20.06 KB

I have done review of the tests for 6.x-3.x branch and edited them a bit. Mainly replaced statements like:

if (...) {
  $this->pass(...);
else {
  $this->fail(...);
}

with simple $this->assertTrue()

Also changed curlExec to have proper call method (GET, PUT, POST, DELETE) displayed.

Is there any specific reason to use json format in calls instead of serialized PHP? I believe we can simplify preparing arguments if we use serialized PHP (we will not have functions services_build_postfields, services_flatten_fields).

kylebrowning’s picture

Status: Needs review » Needs work

Hey ygerasimov, I like the changes, but IM curious why this wasnt done to the ServicesResourceNodeTests.test.

Can they be made to that file so the patch applies cleanly.

I think your version of services might be a bit outdated. See beta2

I restructured the code a bit so that its easier to run tests one at a time. The old way would have taken like10 minutes to run through all the resource endpoints. This way now allows us to have a set of test cases per resource and we can run them one by one, saving a ton of time.

ygerasimov’s picture

Status: Needs work » Needs review
StatusFileSize
new32.87 KB

I have rerolled patch and done following:
1. Changed calls to expect serialized php.
2. Changed formatting (spaces problems).
3. Fixed definition of constructor for class ServicesArgumentException

ygerasimov’s picture

StatusFileSize
new40.38 KB

Here is patch with tests for user resource.

Please note that in order to pass it will need to be fixed issues #1013720: User resource. Method index SQL error when parameters passed. and #967786: Rest_server passing GET arguments

ygerasimov’s picture

StatusFileSize
new54.45 KB

Here is patch with tests for taxonomy resource.

In order to pass patches from following issues should be applied:
#967786: Rest_server passing GET arguments
#1025186: Taxonomy resource. selectNodes method default values

ygerasimov’s picture

StatusFileSize
new0 bytes

Here is patch with all tests including tests for comment and service resources.

Needed patches to pass tests:
#967786: Rest_server passing GET arguments
#1025186: Taxonomy resource. selectNodes method default values
#1028682: System resource. set_variable method

ygerasimov’s picture

StatusFileSize
new66.58 KB

hm... something gone wrong with patch. Another try.

kylebrowning’s picture

Version: 6.x-3.x-dev » 7.x-3.x-dev
Status: Needs review » Needs work

Ok These tests have been comitted for 6.x, setting this to 7.x as thees tests need to be forward ported

ygerasimov’s picture

Status: Needs work » Needs review
StatusFileSize
new34.84 KB

I have started working on tests for D7. Here is node resource test.

In order to pass following patches should be applied:
#1039144: Node resource. Update method Exceptions
#1039142: Node resource. Nid argument type missing

kylebrowning’s picture

Status: Needs review » Needs work

These have been committed, and yes yes yes all tests passed!!

Setting to needs work b/c now all we need Taxonomy, File, Comment, User and system.

ygerasimov’s picture

Status: Needs work » Needs review
StatusFileSize
new19.58 KB

Test is ready for user_resource. There a lot of changes:
1. node_resource.inc -- minor styling changes
2. user_resource.inc
a. delete method default arguments
b. update method rebuilt
c. login action small changes
d. index method small changes
3. services.runtime.inc -- add default value of $data value for constructor of ServicesArgumentException
4. Test for user resource itself.

ALso what I have noticed is in D6 in login method variables called 'name' and 'pass' but in D7 they are 'username' and 'password'. I think we should have the same names (I like full names 'username' and 'password'). Please advise your comments about this so I will prepare patch for both resource and test.

kylebrowning’s picture

Status: Needs review » Closed (fixed)

Were closing this and separating the remaining issues out to their own tickets.