Skip to content

Commit e5b9611

Browse files
committed
Adds a ruby script to test it locally.
1 parent d2b2c64 commit e5b9611

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

TESTING.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,21 @@
33
This assumes you have built and are running the container as depicted in the main `README.md`.
44
In that case, you have a running server on port 5000.
55

6+
## Scripted
7+
8+
You can run the provided Ruby script to issue a request to the server on your native machine.
9+
To do so, if you have some system Ruby installed, you can invoke this command (at the root
10+
of this repository):
11+
12+
```
13+
ruby test/assessment-test.rb
14+
```
15+
16+
This will ping the running server's `/assessment` route building out the appropriate `POST`
17+
request with the test data in the `test` path of the repository.
18+
19+
## Curl
20+
621
You can issue a "test" rubric assessment using hard-coded content that is found in the
722
`test/data` path by using the `/test/assessment` URL. Here, I'm using `curl` to show
823
me the headers and send a `POST` to that route (may take 30 to 50 seconds):

test/assessment-test.rb

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
require 'net/http'
2+
require 'uri'
3+
4+
# This is best done with a better client library than the
5+
# standard one in Ruby, but we wanted this test to work with
6+
# a stock install for the sake of quick testing.
7+
8+
uri = URI('http://localhost:5000')
9+
uri.path = '/assessment'
10+
11+
code = File.read('test/data/u3l23_01.js')
12+
prompt = File.read('test/data/u3l23.txt')
13+
rubric = File.read('test/data/u3l23.csv')
14+
15+
form_data = [
16+
['model', 'gpt-4-0613'],
17+
['code', code],
18+
['prompt', prompt],
19+
['rubric', rubric],
20+
['remove-comments', '1'],
21+
['num-responses', '3'],
22+
['num-passing-grades', '2'],
23+
['temperature', '0.2'],
24+
]
25+
26+
request = Net::HTTP::Post.new(uri)
27+
request.set_form form_data, 'multipart/form-data'
28+
response = Net::HTTP.start(uri.hostname, uri.port) do |http|
29+
http.request(request)
30+
end
31+
32+
puts "Content-Type: #{response.content_type}"
33+
puts response.body

0 commit comments

Comments
 (0)