forked from disarm-dev/douma-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4df3eea
commit 116cd72
Showing
7 changed files
with
72 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module.exports = { | ||
async put(req, res) { | ||
// /seasons | ||
const config_id = req.body.config_id | ||
const config_version = req.body.config_version | ||
const season_start_dates = req.body.season_start_dates | ||
|
||
if (!config_id || !config_version || !season_start_dates) { | ||
return res.status(400).send() | ||
} | ||
|
||
const config_collection = req.db.collection('config'); | ||
const document_id = `${config_id}@${config_version}` | ||
|
||
try { | ||
const result = await config_collection.updateOne({ _id: document_id}, {$set: {'applets.irs_monitor.season_start_dates': season_start_dates}}) | ||
res.send(result) | ||
} catch (e) { | ||
console.log('e', e); | ||
res.status(500).send({error: e.message}) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import {app} from "../../../src/api"; | ||
const request = require('supertest'); | ||
const test = require('ava').test | ||
const {tear_down} = require('../helper') | ||
const { findByUsernamePassword } = require('../../../src/v7/lib/auth') | ||
|
||
|
||
test.afterEach(async () => { | ||
tear_down() | ||
}) | ||
|
||
// TODO: split this out into more and smaller tests | ||
test.serial('Send only season start dates to add a season', async t => { | ||
await request(app).get('/v7/').send() | ||
|
||
const user = findByUsernamePassword('configAdmin', 'passwd') | ||
|
||
const bwa_config = require('../../bwa-config') | ||
|
||
// upload config so it exists | ||
await request(app).post('/v7/config?country=all') | ||
.set('Api-Key', user.key) | ||
.send(bwa_config) | ||
|
||
// update season_start_dates | ||
const season_start_dates = bwa_config.config_data.applets.irs_monitor.season_start_dates; | ||
season_start_dates.push('2018-04-05') | ||
|
||
const data = { | ||
config_id: bwa_config.config_data.instance.slug, | ||
config_version: bwa_config.config_data.config_version, | ||
season_start_dates: season_start_dates | ||
} | ||
|
||
const seasons_result = await request(app).put('/v7/seasons?country=all') | ||
.set('Api-Key', user.key) | ||
.send(data) | ||
|
||
t.deepEqual(seasons_result.status, 200); | ||
|
||
const config_after_update = await request(app).get('/v7/config/bwa?country=all') | ||
|
||
const updated_season_start_dates = config_after_update.body.applets.irs_monitor.season_start_dates | ||
t.deepEqual(updated_season_start_dates, season_start_dates) | ||
}) | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters