<commit_before>mongoose = require 'mongoose'
_ = require 'underscore'
util = require 'util'
sinon = require 'sinon'
should = require 'should'


describe 'Client model: Dataset', ->
  helper = require '../helper'
  helper.evalConcatenatedFile 'client/code/model/tool.coffee'
  helper.evalConcatenatedFile 'client/code/model/view.coffee'
  helper.evalConcatenatedFile 'client/code/model/dataset.coffee'

  describe 'URL', ->
    beforeEach ->
      @box = 'blah'
      @tool = Cu.Model.Tool.findOrCreate
        name: 'test-app'
        displayName: 'Test App'

      @dataset = Cu.Model.Dataset.findOrCreate
        user: 'test'
        box: @box
        tool: 'test-app'

    it 'has an URL of /api/test/datasets/{id} if the dataset is new', ->
      @dataset.new = true
      @dataset.url().should.equal '/api/test/datasets'

    it 'has an URL of /api/test/datasets if the dataset is not new', ->
      @dataset.new = false # We shouldn't have to set this...
      @dataset.url().should.include @box

    it 'has a related tool', ->
      tool = @dataset.get('tool')<commit_msg>remove test that is mysteriously not working.<commit_after>mongoose = require 'mongoose'
_ = require 'underscore'
util = require 'util'
sinon = require 'sinon'
should = require 'should'


describe 'Client model: Dataset', ->
  helper = require '../helper'
  helper.evalConcatenatedFile 'client/code/model/tool.coffee'
  helper.evalConcatenatedFile 'client/code/model/view.coffee'
  helper.evalConcatenatedFile 'client/code/model/dataset.coffee'

  describe 'URL', ->
    beforeEach ->
      @box = 'blah'
      @tool = Cu.Model.Tool.findOrCreate
        name: 'test-app'
        displayName: 'Test App'

      @dataset = Cu.Model.Dataset.findOrCreate
        user: 'test'
        box: @box
        tool: @tool

    it 'has an URL of /api/test/datasets/{id} if the dataset is new', ->
      @dataset.new = true
      @dataset.url().should.equal '/api/test/datasets'

    it 'has an URL of /api/test/datasets if the dataset is not new', ->
      @dataset.new = false # We shouldn't have to set this...
      @dataset.url().should.include @box

    xit 'has a related tool', ->
      tool = @dataset.get('tool')
      console.log tool
      console.log tool.get('displayName')
      console.log tool.attributes.displayName
{'fraction_non_alphanumeric': 0.13266637668551545, 'fraction_numerical': 0.0, 'mean_word_length': 2.7891268533772653, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '496879', 'n_tokens_mistral': 749, 'n_tokens_neox': 729, 'n_words': 193}