<commit_before># encoding: utf-8

require 'helper'

# TODO Rewrite tests with local coap server!

class TestClient < Minitest::Test
  def test_client_get_v4_v6_hostname
    # client = CoRE::CoAP::Client.new
    # answer = client.get('/hello', 'fc00:db20:35b:7399::5')
    # assert_equal([2, 5],answer.mcode)
    # assert_equal('world',answer.payload)

    client = CoRE::CoAP::Client.new
    answer = client.get('/hello', 'coap.me')
    assert_equal([2, 5], answer.mcode)
    assert_equal('world', answer.payload)

    client = CoRE::CoAP::Client.new
    answer = client.get('/hello', '172.16.31.10')
    assert_equal([2, 5], answer.mcode)
    assert_equal('world', answer.payload)
  end

  def test_client_404
    client = CoRE::CoAP::Client.new
    answer = client.get('/hello-this-does-not-exist', 'coap.me')

    assert_equal([4, 4], answer.mcode)
    assert_equal('Not found', answer.payload)<commit_msg>Properly get the IP addresses of 4./6.coap.me<commit_after># encoding: utf-8

require 'helper'

# TODO Rewrite tests with local coap server!

class TestClient < Minitest::Test
  def test_client_get_v4_v6_hostname
    # client = CoRE::CoAP::Client.new
    # answer = client.get('/hello', 'fc00:db20:35b:7399::5')
    # assert_equal([2, 5],answer.mcode)
    # assert_equal('world',answer.payload)

    client = CoRE::CoAP::Client.new
    answer = client.get('/hello', 'coap.me')
    assert_equal([2, 5], answer.mcode)
    assert_equal('world', answer.payload)

    coap_me_ipv4_address = Addrinfo.ip("4.coap.me").ip_address

    client = CoRE::CoAP::Client.new
    answer = client.get('/hello', coap_me_ipv4_address)
    assert_equal([2, 5], answer.mcode)
    assert_equal('world', answer.payload)

    coap_me_ipv6_address = Addrinfo.ip("6.coap.me").ip_address

    client = CoRE::CoAP::Client.new
    answer = client.get('/hello', coap_me_ipv6_address)
    assert_equal([2, 5], answer.mcode)
    assert_equal('world', answer.payload)

  end

  def test_client_404
    client = CoRE::CoAP::Client.new
    answer = client.get('/hello-this-does-not-exist', 'coap.me')

    assert_equal([4, 4], answer.mcode)
    assert_equal('Not found', answer.payload)
{'fraction_non_alphanumeric': 0.15655396016674386, 'fraction_numerical': 0.03195924038906901, 'mean_word_length': 4.08235294117647, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, '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': '1833643', 'n_tokens_mistral': 816, 'n_tokens_neox': 777, 'n_words': 137}