oaeproject/Hilary — pull request #664 by simong (2013-09-16 11:00:43+00:00)
Title: Tincan API test failures

There are a couple issues in the tincan API tests. Here are my failures:

**Grunt style check:**
```
Running "jshint:files" (jshint) task
Linting node_modules/oae-tincanapi/lib/api.js ...ERROR
[L107:C26] W099: Mixed spaces and tabs.
* @return {VerbModel} Mapped TinCan API verb
Linting node_modules/oae-tincanapi/lib/api.js ...ERROR
[L115:C9] W015: Expected 'case' to have an indentation at 5 instead at 9.
case ActivityConstants.verbs.ADD:
Linting node_modules/oae-tincanapi/lib/api.js ...ERROR
[L116:C13] W015: Expected 'verb' to have an indentation at 9 instead at 13.
verb = TinCanAPIConstants.verbs.ADDED;
Linting node_modules/oae-tincanapi/lib/api.js ...ERROR
[L117:C13] W015: Expected 'break' to have an indentation at 9 instead at 13.
break;
Linting node_modules/oae-tincanapi/lib/api.js ...ERROR
[L118:C9] W015: Expected 'case' to have an indentation at 5 instead at 9.
case ActivityConstants.verbs.CREATE:
Linting node_modules/oae-tincanapi/lib/api.js ...ERROR
[L119:C13] W015: Expected 'verb' to have an indentation at 9 instead at 13.
verb = TinCanAPIConstants.verbs.CREATED;
Linting node_modules/oae-tincanapi/lib/api.js ...ERROR
[L120:C13] W015: Expected 'break' to have an indentation at 9 instead at 13.
break;
Linting node_modules/oae-tincanapi/lib/api.js ...ERROR
[L121:C9] W015: Expected 'case' to have an indentation at 5 instead at 9.
case ActivityConstants.verbs.JOIN:
Linting node_modules/oae-tincanapi/lib/api.js ...ERROR
[L122:C13] W015: Expected 'verb' to have an indentation at 9 instead at 13.
verb = TinCanAPIConstants.verbs.JOINED;
Linting node_modules/oae-tincanapi/lib/api.js ...ERROR
[L123:C13] W015: Expected 'break' to have an indentation at 9 instead at 13.
break;
Linting node_modules/oae-tincanapi/lib/api.js ...ERROR
[L124:C9] W015: Expected 'case' to have an indentation at 5 instead at 9.
case ActivityConstants.verbs.POST:
Linting node_modules/oae-tincanapi/lib/api.js ...ERROR
[L125:C13] W015: Expected 'verb' to have an indentation at 9 instead at 13.
verb = TinCanAPIConstants.verbs.POSTED;
Linting node_modules/oae-tincanapi/lib/api.js ...ERROR
[L126:C13] W015: Expected 'break' to have an indentation at 9 instead at 13.
break;
Linting node_modules/oae-tincanapi/lib/api.js ...ERROR
[L127:C9] W015: Expected 'case' to have an indentation at 5 instead at 9.
case ActivityConstants.verbs.SHARE:
Linting node_modules/oae-tincanapi/lib/api.js ...ERROR
[L128:C13] W015: Expected 'verb' to have an indentation at 9 instead at 13.
verb = TinCanAPIConstants.verbs.SHARED;
Linting node_modules/oae-tincanapi/lib/api.js ...ERROR
[L129:C13] W015: Expected 'break' to have an indentation at 9 instead at 13.
break;
Linting node_modules/oae-tincanapi/lib/api.js ...ERROR
[L130:C9] W015: Expected 'case' to have an indentation at 5 instead at 9.
case ActivityConstants.verbs.UPDATE:
Linting node_modules/oae-tincanapi/lib/api.js ...ERROR
[L131:C13] W015: Expected 'verb' to have an indentation at 9 instead at 13.
verb = TinCanAPIConstants.verbs.UPDATED;
Linting node_modules/oae-tincanapi/lib/api.js ...ERROR
[L132:C13] W015: Expected 'break' to have an indentation at 9 instead at 13.
break;
Linting node_modules/oae-tincanapi/lib/api.js ...ERROR
[L133:C9] W015: Expected 'default' to have an indentation at 5 instead at 9.
default:
Linting node_modules/oae-tincanapi/lib/api.js ...ERROR
[L134:C8] W099: Mixed spaces and tabs.
verb = TinCanAPIConstants.verbs.DEFAULT;
Linting node_modules/oae-tincanapi/lib/api.js ...ERROR
[L134:C13] W015: Expected 'verb' to have an indentation at 9 instead at 13.
verb = TinCanAPIConstants.verbs.DEFAULT;
Linting node_modules/oae-tincanapi/lib/api.js ...ERROR
[L135:C8] W099: Mixed spaces and tabs.
break;
Linting node_modules/oae-tincanapi/lib/api.js ...ERROR
[L135:C13] W015: Expected 'break' to have an indentation at 9 instead at 13.
break;
Linting node_modules/oae-tincanapi/lib/constants.js ...ERROR
[L28:C4] W099: Mixed spaces and tabs.
'id': 'http://adlnet.gov/expapi/verbs/interacted',
Linting node_modules/oae-tincanapi/lib/constants.js ...ERROR
[L29:C4] W099: Mixed spaces and tabs.
'display': 'interacted'
```

**Unit tests:**
```
TinCanAPI
◦ verify post TinCan statements: AssertionError: "random-user-l1exRFZfnZ" == "random-user-gyxm2sWz2Z"
at /Users/branden/Source/oaeproject/Hilary/node_modules/oae-tincanapi/tests/test-tincanapi.js:105:36
at Array.forEach (native)
at Function._.each._.forEach (/Users/branden/Source/oaeproject/Hilary/node_modules/underscore/underscore.js:79:11)
at onRequest (/Users/branden/Source/oaeproject/Hilary/node_modules/oae-tincanapi/tests/test-tincanapi.js:104:27)
at /Users/branden/Source/oaeproject/Hilary/node_modules/oae-tincanapi/tests/test-tincanapi.js:57:13
at callbacks (/Users/branden/Source/oaeproject/Hilary/node_modules/express/lib/router/index.js:164:37)
at param (/Users/branden/Source/oaeproject/Hilary/node_modules/express/lib/router/index.js:138:11)
at pass (/Users/branden/Source/oaeproject/Hilary/node_modules/express/lib/router/index.js:145:5)
at Router._dispatch (/Users/branden/Source/oaeproject/Hilary/node_modules/express/lib/router/index.js:173:5)
at Object.router (/Users/branden/Source/oaeproject/Hilary/node_modules/express/lib/router/index.js:33:10)
AssertionError: "random-user-e1emYFWf2b" == "random-user-gyxm2sWz2Z"
at /Users/branden/Source/oaeproject/Hilary/node_modules/oae-tincanapi/tests/test-tincanapi.js:105:36
at Array.forEach (native)
at Function._.each._.forEach (/Users/branden/Source/oaeproject/Hilary/node_modules/underscore/underscore.js:79:11)
at onRequest (/Users/branden/Source/oaeproject/Hilary/node_modules/oae-tincanapi/tests/test-tincanapi.js:104:27)
at /Users/branden/Source/oaeproject/Hilary/node_modules/oae-tincanapi/tests/test-tincanapi.js:57:13
at callbacks (/Users/branden/Source/oaeproject/Hilary/node_modules/express/lib/router/index.js:164:37)
at param (/Users/branden/Source/oaeproject/Hilary/node_modules/express/lib/router/index.js:138:11)
at pass (/Users/branden/Source/oaeproject/Hilary/node_modules/express/lib/router/index.js:145:5)
at Router._dispatch (/Users/branden/Source/oaeproject/Hilary/node_modules/express/lib/router/index.js:173:5)
at Object.router (/Users/branden/Source/oaeproject/Hilary/node_modules/express/lib/router/index.js:33:10)
AssertionError: "random-user-g1VlEKbG2Z" == "random-user-gyxm2sWz2Z"
at /Users/branden/Source/oaeproject/Hilary/node_modules/oae-tincanapi/tests/test-tincanapi.js:105:36
at Array.forEach (native)
at Function._.each._.forEach (/Users/branden/Source/oaeproject/Hilary/node_modules/underscore/underscore.js:79:11)
at onRequest (/Users/branden/Source/oaeproject/Hilary/node_modules/oae-tincanapi/tests/test-tincanapi.js:104:27)
at /Users/branden/Source/oaeproject/Hilary/node_modules/oae-tincanapi/tests/test-tincanapi.js:57:13
at callbacks (/Users/branden/Source/oaeproject/Hilary/node_modules/express/lib/router/index.js:164:37)
at param (/Users/branden/Source/oaeproject/Hilary/node_modules/express/lib/router/index.js:138:11)
at pass (/Users/branden/Source/oaeproject/Hilary/node_modules/express/lib/router/index.js:145:5)
at Router._dispatch (/Users/branden/Source/oaeproject/Hilary/node_modules/express/lib/router/index.js:173:5)
at Object.router (/Users/branden/Source/oaeproject/Hilary/node_modules/express/lib/router/index.js:33:10)
```

1. The style checks should be fixed
2. The assertion failures are getting spit out to the console rather than bubbling up an exception. I think the express error handler is swallowing these and this is the default reaction
3. I think you need to collect *before* performing the activities, as the assertion failure we are seeing here is likely related to having more than just the activities in this test getting collected and verified
4. Unnecessary `_.each` wrapping the users object, it is only 1 user object
5. I don't think executing the callback inside of `onRequest` is necessary in both places
6. Trailing whitespace in this file (line 236)