<commit_before>package mx.ipn.ambienta2mx.smartOwl

import mx.ipn.ambienta2mx.smartOwl.services.SourceService
import spock.lang.Specification
import spock.lang.Unroll
import spock.lang.Shared

class SourceServiceSpec extends Specification{
  
  @Shared service = new SourceService()
  
  @Unroll("Should return the file lines when #_url is consulted") 
  def "Should get the lines from file given an URL"(){
    given:"an url"
      def url = _url 
    when:
      def lines = service.getFileLines(url) 
    then: 
      lines.size() > 0
    where:
      _url << ["http://smn.cna.gob.mx/emas/txt/DF15_10M.TXT",
               "http://smn.cna.gob.mx/emas/txt/DF06_10M.TXT",
               "http://smn.cna.gob.mx/emas/txt/DF08_10M.TXT",
               "http://smn.cna.gob.mx/emas/txt/DF09_10M.TXT"]
  }

  @Unroll("Should return the JSON when https://api.forecast.io/forecast/ is consulted given the latitude #_latitude and longitude #_longitude") 
  def "Should get the lines from file given an URL"(){
    given:"an url"
      def url = "https://api.forecast.io/forecast/"
    when:
      def jsonStructure = service.getJSONStructure(url,_latitude,_longitude)
    then: 
     
    where:
      _latitude | _longitude
        19.395  | -99.025
        19.029  | -98.206 
        23.543  | -103.025
  }

}
<commit_msg>coding #2 updating test for the source service<commit_after>package mx.ipn.ambienta2mx.smartOwl

import mx.ipn.ambienta2mx.smartOwl.services.SourceService
import spock.lang.Specification
import spock.lang.Unroll
import spock.lang.Shared
import java.util.Properties

class SourceServiceSpec extends Specification{
  
  @Shared service = new SourceService()
  
  @Unroll("Should return the file lines when #_url is consulted") 
  def "Should get the lines from file given an URL"(){
    given:"an url"
      def url = _url 
    when:
      def lines = service.getFileLines(url) 
    then: 
      lines.size() > 0
    where:
      _url << ["http://smn.cna.gob.mx/emas/txt/DF15_10M.TXT",
               "http://smn.cna.gob.mx/emas/txt/DF06_10M.TXT",
               "http://smn.cna.gob.mx/emas/txt/DF08_10M.TXT",
               "http://smn.cna.gob.mx/emas/txt/DF09_10M.TXT"]
  }


  @Unroll("Should return the JSON when url is consulted given the latitude #_latitude and longitude #_longitude") 
  def "Should get the lines from file given an URL"(){
    given:"an url and the token from source"
      def propertiesFile = new Properties()
      def inputStream = this.class.classLoader.getResourceAsStream("sourcesInfo.properties")
      propertiesFile.load(inputStream) 
      def url = propertiesFile.getProperty "source.url"
      def token = propertiesFile.getProperty "source.token"

    and:"the location points"
      def locationPoints = [latitude:_latitude,
                           longitude:_longitude]
    when:
      def jsonStructure = service.getJSONFromUrlWithToken(url,token,locationPoints)

    then: 
      jsonStructure.humidity
      jsonStructure.ozone
      jsonStructure.precipIntensity
    
    where:
      _latitude | _longitude
        19.395  | -99.025
        19.029  | -98.206 
        23.543  | -103.025
  }

}

{'fraction_non_alphanumeric': 0.10864745011086474, 'fraction_numerical': 0.031992397846056383, 'mean_word_length': 2.6466512702078524, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '2770208', 'n_tokens_mistral': 1128, 'n_tokens_neox': 1040, 'n_words': 235}