| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -26,11 +26,10 @@ describe('/model', () => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          should(group).have.only.keys('group', 'models');
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          should(group).have.property('group').be.type('string');
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          should(group.models).matchEach(model => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            should(model).have.only.keys('_id', 'name', 'url', 'label');
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            should(model).have.only.keys('_id', 'name', 'url');
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            should(model).have.property('_id').be.type('string');
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            should(model).have.property('name').be.type('string');
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            should(model).have.property('url').be.type('string');
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            should(model).have.property('label').be.type('string');
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        done();
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -48,7 +47,7 @@ describe('/model', () => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        should(res.body).matchEach(group => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          should(group).have.only.keys('group', 'models');
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          should(group).have.property('group').be.type('string');
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          should(group).have.property('models', [{_id: '120000000000000000000001', name: 'Model A', url: 'http://model-a.com', label: 'ml/g'}]);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          should(group).have.property('models', [{_id: '120000000000000000000001', name: 'Model A', url: 'http://model-a.com'}]);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        done();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      });
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -77,7 +76,7 @@ describe('/model', () => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        url: '/model/VN',
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        auth: {basic: 'admin'},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        httpStatus: 200,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {name: 'Model C', url: 'http://model-c.com', label: 'ml/g'}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {name: 'Model C', url: 'http://model-c.com'}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      }).end((err, res) => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        if (err) return done(err);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        should(res.body).be.eql({status: 'OK'});
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -85,7 +84,6 @@ describe('/model', () => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          if (err) return done(err);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          const model = res.models.find(e => e.name === 'Model C');
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          should(model).have.property('url', 'http://model-c.com');
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          should(model).have.property('label', 'ml/g');
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          done();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      });
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -96,7 +94,7 @@ describe('/model', () => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        url: '/model/classification',
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        auth: {basic: 'admin'},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        httpStatus: 200,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {name: 'Model 0.1', url: 'http://model-0-1.com', label: 'group'}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {name: 'Model 0.1', url: 'http://model-0-1.com'}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      }).end((err, res) => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        if (err) return done(err);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        should(res.body).be.eql({status: 'OK'});
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -104,10 +102,9 @@ describe('/model', () => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          if (err) return done(err);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          should(res).have.only.keys('_id', 'group', 'models', '__v');
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          should(res).have.property('group', 'classification');
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          should(res.models[0]).have.only.keys('_id', 'name', 'url', 'label');
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          should(res.models[0]).have.only.keys('_id', 'name', 'url');
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          should(res.models[0]).have.property('name', 'Model 0.1');
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          should(res.models[0]).have.property('url', 'http://model-0-1.com');
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          should(res.models[0]).have.property('label', 'group');
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          done();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      });
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -118,7 +115,7 @@ describe('/model', () => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        url: '/model/VN',
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        auth: {basic: 'admin'},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        httpStatus: 200,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {name: 'Model A', url: 'http://model-a-new.com', label: 'ml/cm3'}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {name: 'Model A', url: 'http://model-a-new.com'}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      }).end((err, res) => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        if (err) return done(err);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        should(res.body).be.eql({status: 'OK'});
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -126,26 +123,6 @@ describe('/model', () => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          if (err) return done(err);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          const model = res.models.find(e => e.name === 'Model A');
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          should(model).have.property('url', 'http://model-a-new.com');
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          should(model).have.property('label', 'ml/cm3');
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          done();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    it('accepts an empty label', done => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      TestHelper.request(server, done, {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        method: 'post',
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        url: '/model/VN',
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        auth: {basic: 'admin'},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        httpStatus: 200,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {name: 'Model C', url: 'http://model-c.com', label: ''}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      }).end((err, res) => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        if (err) return done(err);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        should(res.body).be.eql({status: 'OK'});
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        ModelModel.findOne({group: 'VN'}).lean().exec((err, res) => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          if (err) return done(err);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          const model = res.models.find(e => e.name === 'Model C');
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          should(model).have.property('url', 'http://model-c.com');
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          should(model).have.property('label', '');
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          done();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      });
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -156,7 +133,7 @@ describe('/model', () => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        url: '/model/VN',
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        auth: {basic: 'admin'},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        httpStatus: 400,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {name: '', url: 'http://model-c.com', label: 'ml/g'},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {name: '', url: 'http://model-c.com'},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        res:{status: 'Invalid body format', details: '"name" is not allowed to be empty'}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    });
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -166,7 +143,7 @@ describe('/model', () => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        url: '/model/VN',
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        auth: {basic: 'admin'},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        httpStatus: 400,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {url: 'http://model-c.com', label: 'ml/g'},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {url: 'http://model-c.com'},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        res:{status: 'Invalid body format', details: '"name" is required'}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    });
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -176,7 +153,7 @@ describe('/model', () => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        url: '/model/VN',
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        auth: {basic: 'admin'},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        httpStatus: 400,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {name: 'Model C', url: 'model-c', label: 'ml/g'},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {name: 'Model C', url: 'model-c'},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        res:{status: 'Invalid body format', details: '"url" must be a valid uri'}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    });
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -186,7 +163,7 @@ describe('/model', () => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        url: '/model/VN',
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        auth: {basic: 'admin'},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        httpStatus: 400,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {name: 'Model C', label: 'ml/g'},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {name: 'Model C'},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        res:{status: 'Invalid body format', details: '"url" is required'}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    });
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -196,7 +173,7 @@ describe('/model', () => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        url: '/model/VN',
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        auth: {basic: 'janedoe'},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        httpStatus: 403,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {name: 'Model C', url: 'http://model-c.com', label: 'ml/g'}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {name: 'Model C', url: 'http://model-c.com'}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    it('rejects an API key', done => {
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -205,7 +182,7 @@ describe('/model', () => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        url: '/model/VN',
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        auth: {key: 'admin'},
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        httpStatus: 401,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {name: 'Model C', url: 'http://model-c.com', label: 'ml/g'}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {name: 'Model C', url: 'http://model-c.com'}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    it('rejects an unauthorized request', done => {
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -213,7 +190,7 @@ describe('/model', () => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        method: 'post',
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        url: '/model/VN',
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        httpStatus: 401,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {name: 'Model C', url: 'http://model-c.com', label: 'ml/g'}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        req: {name: 'Model C', url: 'http://model-c.com'}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				  });
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@@ -232,10 +209,9 @@ describe('/model', () => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          if (err) return done(err);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          should(res).have.only.keys('_id', 'group', 'models');
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          should(res).have.property('group', 'VN');
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          should(res.models[0]).have.only.keys('_id', 'name', 'url', 'label');
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          should(res.models[0]).have.only.keys('_id', 'name', 'url');
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          should(res.models[0]).have.property('name', 'Model B');
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          should(res.models[0]).have.property('url', 'http://model-b.com');
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          should(res.models[0]).have.property('label', 'ml/g');
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				          done();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				      });
 | 
			
		
		
	
	
		
			
				
					
					| 
						
					 | 
				
			
			 | 
			 | 
			
				 
 |