<commit_before>require 'test_helper'

class RateStoreTest < Minitest::Test
  TEST_XML = '
  <?xml version="1.0" encoding="UTF-8"?>
  <gesmes:Envelope xmlns:gesmes="http://www.gesmes.org/xml/2002-08-01" xmlns="http://www.ecb.int/vocabulary/2002-08-01/eurofxref">
      <gesmes:subject>Reference rates</gesmes:subject>
      <gesmes:Sender>
          <gesmes:name>European Central Bank</gesmes:name>
      </gesmes:Sender>
      <Cube>
          <Cube time="2017-06-02">
              <Cube currency="USD" rate="1.1217" />
              <Cube currency="GBP" rate="0.87268" />
          </Cube>
          <Cube time="2017-06-01">
              <Cube currency="USD" rate="1.1219" />
              <Cube currency="GBP" rate="0.8723" />
          </Cube>
      </Cube>
  </gesmes:Envelope>'

  def setup
    @store = FxPotato::RateStore.new(TEST_XML)
  end

  def test_get_returns_something
    assert @store.get(Date.new(2017, 6, 1), 'GBP')
  end

  def test_get_returns_the_correct_rate
    assert_equal 0.8723, @store.get(Date.new(2017, 6, 1), 'GBP')
    assert_equal 1.1219, @store.get(Date.new(2017, 6, 1), 'USD')
  end
end<commit_msg>remove magic numbers from store test<commit_after>require 'test_helper'

class RateStoreTest < Minitest::Test
  USD_06_02 = 1.1217
  GBP_06_02 = 0.87268
  USD_06_01 = 1.1219
  GBP_06_01 = 0.8723
  TEST_XML = "
  <?xml version=\"1.0\" encoding=\"UTF-8\"?>
  <gesmes:Envelope xmlns:gesmes=\"http://www.gesmes.org/xml/2002-08-01\" xmlns=\"http://www.ecb.int/vocabulary/2002-08-01/eurofxref\">
      <gesmes:subject>Reference rates</gesmes:subject>
      <gesmes:Sender>
          <gesmes:name>European Central Bank</gesmes:name>
      </gesmes:Sender>
      <Cube>
          <Cube time=\"2017-06-02\">
              <Cube currency=\"USD\" rate=\"#{USD_06_02}\" />
              <Cube currency=\"GBP\" rate=\"#{GBP_06_02}\" />
          </Cube>
          <Cube time=\"2017-06-01\">
              <Cube currency=\"USD\" rate=\"#{USD_06_01}\" />
              <Cube currency=\"GBP\" rate=\"#{GBP_06_01}\" />
          </Cube>
      </Cube>
  </gesmes:Envelope>"

  def setup
    @store = FxPotato::RateStore.new(TEST_XML)
  end

  def test_get_returns_something
    assert @store.get(Date.new(2017, 6, 1), 'GBP')
  end

  def test_get_returns_the_correct_rate
    assert_equal GBP_06_02, @store.get(Date.new(2017, 6, 2), 'GBP')
    assert_equal USD_06_02, @store.get(Date.new(2017, 6, 2), 'USD')
    assert_equal GBP_06_01, @store.get(Date.new(2017, 6, 1), 'GBP')
    assert_equal USD_06_01, @store.get(Date.new(2017, 6, 1), 'USD')
  end
end
{'fraction_non_alphanumeric': 0.17360840794083301, 'fraction_numerical': 0.08485792137018296, 'mean_word_length': 2.8130563798219583, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 2, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 8}, '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': '6064093', 'n_tokens_mistral': 1130, 'n_tokens_neox': 980, 'n_words': 162}