<commit_before>process.env.NODE_ENV = 'development';
var app = require('../app');
var request = require('supertest');
var chai = require("chai");
chai.should();
chai.use(require('chai-things'));

// check admin page 
describe('GET /admin', function(){
  it('admin page should load', function(done){
    request(app)
      .get('/admin')
      .expect(200, done);
  })
})

// register a station
describe('POST /api/station/D0:FB:DB:D4:21:15', function(){
  it('Station should register', function(done){
    request(app)
      .post('/api/station/D0:FB:DB:D4:21:15')
      .expect(201, done);
  })
})

// update station ip
describe('POST /api/station/D0:FB:DB:D4:21:15', function(){
  it('Station should update it\'s ip', function(done){
    request(app)
      .post('/api/station/D0:FB:DB:D4:21:15')
      .expect(200, done);
  })
})

// post config as station
describe('POST /api/station', function(){
  it('Config for station should be updated and ip address set', function(done){
    request(app)
      .post('/api/station')
      .set('station-mgr','1') 
      .set('Content-Type', 'application/json')
      .send(
            {
              "device_control" : {
                 "api" : {
                    "run" : "1"
                 },
                 "dvmon" : {
                    "run" : "0"
                 }
              },
              "devices" : "all",
              "macaddress" : "D0:FB:DB:D4:21:15",
              "mixer" : {
                 "host" : "localhost",
                 "port" : "1234"
              },
              "nickname" : "stationtest",
              "record_path" : "/tmp/$room/$date",
              "roles" : [
                { "role": "mixer" },
                { "role": "record" },
                { "role": "ingest" },
                { "role": "stream" }
              ],
              "room" : "",
              "run" : "0",
              "stream" : {
                 "host" : "1.2.3.4",
                 "password" : "password",
                 "port" : "1337",
                 "stream" : "test.ogg"
              }
            }
      )
      .expect(200, done);
  })
})

// Get station information
describe('GET /api/station/D0:FB:DB:D4:21:15', function(){
  it('Get station details', function(done){
    request(app)
      .get('/api/stations/D0:FB:DB:D4:21:15')
      .expect('Content-Type', /json/)
      .expect(200)
      .end(function(err, res) {
        // settings object
        res.body.should.have.property('settings').to.be.an('object')
        // device control object
        res.body.settings.should.have.property('device_control').to.be.an('object')
        res.body.settings.should.have.property('device_control').to.have.deep.property('api.run', '1');
        res.body.settings.should.have.property('device_control').to.have.deep.property('dvmon.run', '0');
        // devices<commit_msg>added ip test<commit_after>process.env.NODE_ENV = 'development';
var app = require('../app');
var request = require('supertest');
var chai = require("chai");
chai.should();
chai.use(require('chai-things'));

// check admin page 
describe('GET /admin', function(){
  it('admin page should load', function(done){
    request(app)
      .get('/admin')
      .expect(200, done);
  })
})

// register a station
describe('POST /api/station/D0:FB:DB:D4:21:15', function(){
  it('Station should register', function(done){
    request(app)
      .post('/api/station/D0:FB:DB:D4:21:15')
      .expect(201, done);
  })
})

// update station ip
describe('POST /api/station/D0:FB:DB:D4:21:15', function(){
  it('Station should update it\'s ip', function(done){
    request(app)
      .post('/api/station/D0:FB:DB:D4:21:15')
      .expect(200, done);
  })
})

// post config as station
describe('POST /api/station', function(){
  it('Config for station should be updated and ip address set', function(done){
    request(app)
      .post('/api/station')
      .set('station-mgr','1') 
      .set('Content-Type', 'application/json')
      .send(
            {
              "device_control" : {
                 "api" : {
                    "run" : "1"
                 },
                 "dvmon" : {
                    "run" : "0"
                 }
              },
              "devices" : "all",
              "macaddress" : "D0:FB:DB:D4:21:15",
              "mixer" : {
                 "host" : "localhost",
                 "port" : "1234"
              },
              "nickname" : "stationtest",
              "record_path" : "/tmp/$room/$date",
              "roles" : [
                { "role": "mixer" },
                { "role": "record" },
                { "role": "ingest" },
                { "role": "stream" }
              ],
              "room" : "",
              "run" : "0",
              "stream" : {
                 "host" : "1.2.3.4",
                 "password" : "password",
                 "port" : "1337",
                 "stream" : "test.ogg"
              }
            }
      )
      .expect(200, done);
  })
})

// Get station information
describe('GET /api/station/D0:FB:DB:D4:21:15', function(){
  it('Get station details', function(done){
    request(app)
      .get('/api/stations/D0:FB:DB:D4:21:15')
      .expect('Content-Type', /json/)
      .expect(200)
      .end(function(err, res) {
        // ip
        res.body.ip.should.equal('127.0.0.1');
        // settings object
        res.body.should.have.property('settings').to.be.an('object');
        // device control object
        res.body.settings.should.have.property('device_control').to.be.an('object');
        res.body.settings.should.have.property('device_control').to.have.deep.property('api.run', '1');
        res.body.settings.should.have.property('device_control').to.have.deep.property('dvmon.run', '0');
        // devices
{'fraction_non_alphanumeric': 0.18630326030705538, 'fraction_numerical': 0.02691047093324133, 'mean_word_length': 1.7969126869271588, 'pattern_counts': {'":': 8, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 3, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2459075', 'n_tokens_mistral': 1907, 'n_tokens_neox': 1824, 'n_words': 311}