Comments (4)
Started working on this, kashav@77c218a. Coverage is up to 81%.
Running into some problems with courses/filter
when filtering for matched sections with that added matched_meeting_sections
list. Any idea how to deal with that?
from cobalt.
You might be able to use a .expect()
call like this:
.expect(res => {
let expected = testData.filter(doc => {
return /* doc filter here */
})
expected.matched_meeting_sections = []
for (let i = 0; i < expected.meeting_sections.length, i++) {
let expectedSections = expected.meeting_sections[i].filter(m => {
return /* meeting section filter here */
})
if (expectedSections.length > 0) {
expected.matched_meeting_sections.push(expectedSections)
}
}
res.body = expected;
})
Haven't tested that though, so may need some tweaking. If it doesn't work at all because of ordering / some other obscure issue, you can hardcode the answer too since the test data will remain static.
from cobalt.
So it turns out the problem was that each meeting_sections
and matched_meeting_sections
object had a unique _id
key. Neither your solution nor hardcoding worked cause of that.
I tried removing all _id
keys when formatting the response:
for(let doc of docs) {
for (let section of ['meeting_sections', 'matched_meeting_sections']) {
if (doc.value.hasOwnProperty(section)) {
for (let i = 0; i < doc.value[section].length; i++) {
delete doc.value[section][i]._id
for (let j = 0; j < doc.value[section][i].times.length; j++) {
delete doc.value[section][i].times[j]._id
}
}
}
}
if (doc.value.hasOwnProperty('__v')) {
delete doc.value.__v
}
delete doc.value._id
formattedDocs.push(doc.value)
}
Tests are running fine now, but coverage seems to be failing for every case that checks for a meeting_section
.
Test:
test.cb('/filter?q=size:15', t => {
request(cobalt.Server)
.get('/1.0/courses/filter?q=size:15')
.expect('Content-Type', /json/)
.expect(200)
.end((err, res) => {
if (err) t.fail(err.message)
t.pass()
t.end()
})
})
Response:
courses › test › /filter?q=size:15
expected 200 "OK", got 500 "Internal Server Error"
from cobalt.
Hmm, that's not good. We shouldn't have _id
at all. I'll look into this and get back to you.
from cobalt.
Related Issues (20)
- Transportation API HOT 4
- Athletics API HOT 4
- Date parameters in filter endpoints should support multiple formats? HOT 3
- Exams API HOT 4
- Events API HOT 1
- Building API: keys out of order HOT 5
- Time and Date updates HOT 2
- Revamp how we filter HOT 8
- Should we discontinue /search in favour of /filter? HOT 2
- Food API: Move filter to newer ParseQuery model + abstract the `open` filter
- Campus filter not working? HOT 1
- 404 for cdf/labs and printers HOT 6
- Requires database to be called cobalt HOT 7
- DeprecationWarning: Mongoose: mpromise (mongoose's default promise library) is deprecated, plug in your own promise library instead HOT 1
- GET courses doesn't return any locations. HOT 2
- Problem in self-hosting HOT 6
- API server down? HOT 2
- 502 bad gateway HOT 2
- UTM courses not returning full course codes for its prerequisites
- API 502 responses HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cobalt.