DEV: Apply syntax_tree formatting to script/*

This commit is contained in:
David Taylor
2023-01-07 11:53:14 +00:00
parent ff508d1ae5
commit 436b3b392b
143 changed files with 8905 additions and 7353 deletions

View File

@ -1,26 +1,28 @@
# frozen_string_literal: true
require 'minitest/autorun'
require_relative '../create_title.rb'
require "minitest/autorun"
require_relative "../create_title.rb"
class TestCreateTitle < Minitest::Test
def test_create_title_1
body = "@GreatCheerThreading \nWhere can I find information on how GCTS stacks up against the competition? What are the key differentiators?"
body =
"@GreatCheerThreading \nWhere can I find information on how GCTS stacks up against the competition? What are the key differentiators?"
expected = "Where can I find information on how GCTS stacks up against the competition?"
title = CreateTitle.from_body body
assert_equal(expected, title)
end
def test_create_title_2
body = "GCTS in 200 stores across town. How many threads per inch would you guess? @GreatCheerThreading"
body =
"GCTS in 200 stores across town. How many threads per inch would you guess? @GreatCheerThreading"
expected = "GCTS in 200 stores across town. How many threads per inch would you guess?"
title = CreateTitle.from_body body
assert_equal(expected, title)
end
def test_create_title_3
body = "gFabric Sheets 1.2 now has Great Cheer Threads, letting you feel the softness running through the cotton fibers."
body =
"gFabric Sheets 1.2 now has Great Cheer Threads, letting you feel the softness running through the cotton fibers."
expected = "gFabric Sheets 1.2 now has Great Cheer Threads, letting you feel the softness..."
title = CreateTitle.from_body body
assert_equal(expected, title)
@ -34,49 +36,56 @@ class TestCreateTitle < Minitest::Test
end
def test_create_title_5
body = "One sentence. Two sentence. Three sentence. Four is going to go on and on for more words than we want."
body =
"One sentence. Two sentence. Three sentence. Four is going to go on and on for more words than we want."
expected = "One sentence. Two sentence. Three sentence."
title = CreateTitle.from_body body
assert_equal(expected, title)
end
def test_create_title_6
body = "Anyone know of any invite codes for www.greatcheer.io (the Great Cheer v2 site)?\n\n//cc @RD @GreatCheerThreading"
body =
"Anyone know of any invite codes for www.greatcheer.io (the Great Cheer v2 site)?\n\n//cc @RD @GreatCheerThreading"
expected = "Anyone know of any invite codes for www.greatcheer.io (the Great Cheer v2 site)?"
title = CreateTitle.from_body body
assert_equal(expected, title)
end
def test_create_title_6b
body = "Anyone know of any invite codes for www.greatcheer.io (the Great Cheer v2 site of yore)?\n\n//cc @RD @GreatCheerThreading"
body =
"Anyone know of any invite codes for www.greatcheer.io (the Great Cheer v2 site of yore)?\n\n//cc @RD @GreatCheerThreading"
expected = "Anyone know of any invite codes for www.greatcheer.io (the Great Cheer v2 site..."
title = CreateTitle.from_body body
assert_equal(expected, title)
end
def test_create_title_6c
body = "Anyone know of any invite codes for www.greatcheer.io?! (the Great Cheer v2 site of yore)?\n\n//cc @RD @GreatCheerThreading"
body =
"Anyone know of any invite codes for www.greatcheer.io?! (the Great Cheer v2 site of yore)?\n\n//cc @RD @GreatCheerThreading"
expected = "Anyone know of any invite codes for www.greatcheer.io?!"
title = CreateTitle.from_body body
assert_equal(expected, title)
end
def test_create_title_7
body = "@GreatCheerThreading \n\nDoes anyone know what the plan is to move to denser 1.2 threads for GCTS?\n\nI have a customer interested in the higher thread counts offered in 1.2."
body =
"@GreatCheerThreading \n\nDoes anyone know what the plan is to move to denser 1.2 threads for GCTS?\n\nI have a customer interested in the higher thread counts offered in 1.2."
expected = "Does anyone know what the plan is to move to denser 1.2 threads for GCTS?"
title = CreateTitle.from_body body
assert_equal(expected, title)
end
def test_create_title_8
body = "@GreatCheerThreading @FabricWeavingWorldwide \n\nI was just chatting with a customer, after receiving this email:\n\n\"Ours is more of a ‘conceptual’ question. We have too much fiber"
body =
"@GreatCheerThreading @FabricWeavingWorldwide \n\nI was just chatting with a customer, after receiving this email:\n\n\"Ours is more of a ‘conceptual’ question. We have too much fiber"
expected = "I was just chatting with a customer, after receiving this email:"
title = CreateTitle.from_body body
assert_equal(expected, title)
end
def test_create_title_9
body = "Hi,\n\nDoes anyone have a PPT deck on whats new in cotton (around 10 or so slides) nothing to detailed as per what we have in the current 1.x version?\n\nI am not after a what's coming in cotton 2"
body =
"Hi,\n\nDoes anyone have a PPT deck on whats new in cotton (around 10 or so slides) nothing to detailed as per what we have in the current 1.x version?\n\nI am not after a what's coming in cotton 2"
expected = "Does anyone have a PPT deck on whats new in cotton (around 10 or so slides)..."
title = CreateTitle.from_body body
assert_equal(expected, title)
@ -90,7 +99,8 @@ class TestCreateTitle < Minitest::Test
end
def test_create_title_11
body = "Hi Guys,\nI'm working with #gtcs and one of the things we're playing with is TC. What better tool to demo and use than our own \nhttps://greatcheerthreading.com/themostthreads/cool-stuff\n\nThis used to work great in 2013,"
body =
"Hi Guys,\nI'm working with #gtcs and one of the things we're playing with is TC. What better tool to demo and use than our own \nhttps://greatcheerthreading.com/themostthreads/cool-stuff\n\nThis used to work great in 2013,"
expected = "I'm working with #gtcs and one of the things we're playing with is TC."
title = CreateTitle.from_body body
assert_equal(expected, title)
@ -104,10 +114,10 @@ class TestCreateTitle < Minitest::Test
end
def test_create_title_13
body = "Embroidered TC ... http://blogs.greatcheerthreading.com/thread/embroidering-the-threads-is-just-the-beginning\n@SoftStuff @TightWeave and team hopefully can share their thoughts on this recent post."
body =
"Embroidered TC ... http://blogs.greatcheerthreading.com/thread/embroidering-the-threads-is-just-the-beginning\n@SoftStuff @TightWeave and team hopefully can share their thoughts on this recent post."
expected = "and team hopefully can share their thoughts on this recent post."
title = CreateTitle.from_body body
assert_equal(expected, title)
end
end

View File

@ -1,6 +1,7 @@
# frozen_string_literal: true
USERS = '{
USERS =
'{
"users": [
{
"contact_info": {
@ -1082,7 +1083,8 @@ USERS = '{
]
}'
MESSAGES = '{
MESSAGES =
'{
"messages": [
{
"id": 426,
@ -5429,7 +5431,8 @@ MESSAGES = '{
"messages_next_page": 2
}'
MESSAGES_PG_2 = '{
MESSAGES_PG_2 =
'{
"messages": [
{
"id": 386,

View File

@ -1,21 +1,20 @@
# frozen_string_literal: true
require 'minitest/autorun'
require 'yaml'
require_relative '../socialcast_api.rb'
require_relative './test_data.rb'
require "minitest/autorun"
require "yaml"
require_relative "../socialcast_api.rb"
require_relative "./test_data.rb"
class TestSocialcastApi < Minitest::Test
DEBUG = false
def initialize(args)
config = YAML::load_file(File.join(__dir__, 'config.ex.yml'))
@domain = config['domain']
@username = config['username']
@password = config['password']
@kb_id = config['kb_id']
@question_id = config['question_id']
config = YAML.load_file(File.join(__dir__, "config.ex.yml"))
@domain = config["domain"]
@username = config["username"]
@password = config["password"]
@kb_id = config["kb_id"]
@question_id = config["question_id"]
super args
end
@ -30,18 +29,18 @@ class TestSocialcastApi < Minitest::Test
end
def test_base_url
assert_equal 'https://demo.socialcast.com/api', @socialcast.base_url
assert_equal "https://demo.socialcast.com/api", @socialcast.base_url
end
def test_headers
headers = @socialcast.headers
assert_equal 'Basic ZW1pbHlAc29jaWFsY2FzdC5jb206ZGVtbw==', headers[:Authorization]
assert_equal 'application/json', headers[:Accept]
assert_equal "Basic ZW1pbHlAc29jaWFsY2FzdC5jb206ZGVtbw==", headers[:Authorization]
assert_equal "application/json", headers[:Accept]
end
def test_list_users
users = @socialcast.list_users
expected = JSON.parse(USERS)['users'].sort { |u| u['id'] }
expected = JSON.parse(USERS)["users"].sort { |u| u["id"] }
assert_equal 15, users.size
assert_equal expected[0], users[0]
end
@ -53,14 +52,14 @@ class TestSocialcastApi < Minitest::Test
def test_list_messages
messages = @socialcast.list_messages
expected = JSON.parse(MESSAGES)['messages'].sort { |m| m['id'] }
expected = JSON.parse(MESSAGES)["messages"].sort { |m| m["id"] }
assert_equal 20, messages.size
check_keys expected[0], messages[0]
end
def test_messages_next_page
messages = @socialcast.list_messages(page: 2)
expected = JSON.parse(MESSAGES_PG_2)['messages'].sort { |m| m['id'] }
expected = JSON.parse(MESSAGES_PG_2)["messages"].sort { |m| m["id"] }
assert_equal 20, messages.size
check_keys expected[0], messages[0]
end
@ -69,18 +68,16 @@ class TestSocialcastApi < Minitest::Test
def check_keys(expected, actual)
msg = "### caller[0]:\nKey not found in actual keys: #{actual.keys}\n"
expected.keys.each do |k|
assert (actual.keys.include? k), "#{k}"
end
expected.keys.each { |k| assert (actual.keys.include? k), "#{k}" }
end
def debug(message, show = false)
if show || DEBUG
puts '### ' + caller[0]
puts ''
puts "### " + caller[0]
puts ""
puts message
puts ''
puts ''
puts ""
puts ""
end
end
end