Skip to content

Commit

Permalink
Backfill parser tests with FPL data from 2024-12-14 through 2024-12-20
Browse files Browse the repository at this point in the history
  • Loading branch information
dharmab committed Jan 2, 2025
1 parent 927faec commit b735096
Show file tree
Hide file tree
Showing 10 changed files with 268 additions and 69 deletions.
2 changes: 1 addition & 1 deletion docs/PLAYER.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Your callsign should be unique within a server. If multiple players have the sam

Avoid:

* Names that contain brevity codewords, including "alpha", "radio", "comm", "bogey", "picture", "declare", "snaplock", "spiked", "bullseye".
* Names that contain or are similar to brevity codewords, including "alpha", "radio", "comm", "bogey", "picture", "declare", "snaplock", "spiked", "bullseye". For example, "Spade" can be difficult to distinguish from "SPIKE"
* Names that are hard to distinguish, like "Spare"/"Spear", "Jester"/"Gesture", "Witch"/"Which". The bot will make a best effort, but may be less accurate.
* Names that sound similar to numbers. For example, "Knight" sounds similar to "Nine", "Fort" sounds like "Four"
* Names that aren't widely recognized words in common parlance, like "Razgriz" or "Beskar". The bot will make a best effort, but may be less accurate.
Expand Down
56 changes: 56 additions & 0 deletions pkg/parser/alphacheck_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package parser

import (
"testing"

"github.com/dharmab/skyeye/pkg/brevity"
"github.com/stretchr/testify/require"
)

func TestParserAlphaCheck(t *testing.T) {
t.Parallel()
testCases := []parserTestCase{
{
text: "ANYFACE, HORNET 1, CHECKING IN AS FRAGGED, REQUEST ALPHA CHECK DEPOT",
expected: &brevity.AlphaCheckRequest{
Callsign: "hornet 1",
},
},
{
text: "anyface intruder 11 alpha check",
expected: &brevity.AlphaCheckRequest{
Callsign: "intruder 1 1",
},
},
{
text: "anyface intruder 11, checking in as fragged, request alpha check bullseye",
expected: &brevity.AlphaCheckRequest{
Callsign: "intruder 1 1",
},
},
{
text: TestCallsign + "intruder 11 alpha check",
expected: &brevity.AlphaCheckRequest{
Callsign: "intruder 1 1",
},
},
{
text: TestCallsign + "Gunfighter 2-1, AlphaJack, Bullseye.",
expected: &brevity.AlphaCheckRequest{
Callsign: "gunfighter 2 1",
},
},
{
text: TestCallsign + " HORNET 12, ALPHACHEK",
expected: &brevity.AlphaCheckRequest{
Callsign: "hornet 1 2",
},
},
}
runParserTestCases(t, New(TestCallsign, true), testCases, func(t *testing.T, test parserTestCase, request any) {
t.Helper()
expected := test.expected.(*brevity.AlphaCheckRequest)
actual := request.(*brevity.AlphaCheckRequest)
require.Equal(t, expected.Callsign, actual.Callsign)
})
}
126 changes: 126 additions & 0 deletions pkg/parser/bogeydope_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,132 @@ func TestParserBogeyDope(t *testing.T) {
Filter: brevity.Aircraft,
},
},
{
text: TestCallsign + ", CAT1/1, request BOGUETTO.",
expected: &brevity.BogeyDopeRequest{
Callsign: "cat 1 1",
Filter: brevity.Aircraft,
},
},
{
text: TestCallsign + "Cat 1.1 request BOGUE.",
expected: &brevity.BogeyDopeRequest{
Callsign: "cat 1 1",
Filter: brevity.Aircraft,
},
},
{
text: TestCallsign + "Serptants, 6-8, Bogeydove.",
expected: &brevity.BogeyDopeRequest{
Callsign: "serptants 6 8",
Filter: brevity.Aircraft,
},
},
{
text: TestCallsign + ", Spartan 1-1, Boogitope.",
expected: &brevity.BogeyDopeRequest{
Callsign: "spartan 1 1",
Filter: brevity.Aircraft,
},
},
{
text: TestCallsign + ", COPWIPE11, BOKI NOLA.",
expected: &brevity.BogeyDopeRequest{
Callsign: "copwipe 1 1",
Filter: brevity.Aircraft,
},
},
{
text: TestCallsign + ", Hornet one two, Bowie dope.",
expected: &brevity.BogeyDopeRequest{
Callsign: "hornet 1 2",
Filter: brevity.Aircraft,
},
},
{
text: TestCallsign + ", radon11, boobydope.",
expected: &brevity.BogeyDopeRequest{
Callsign: "radon 1 1",
Filter: brevity.Aircraft,
},
},
{
text: TestCallsign + ", stubs on one, poke it up.",
expected: &brevity.BogeyDopeRequest{
Callsign: "stubs on 1",
Filter: brevity.Aircraft,
},
},
{
text: TestCallsign + ", Hollywood 11, VOGUE IT UP!",
expected: &brevity.BogeyDopeRequest{
Callsign: "hollywood 1 1",
Filter: brevity.Aircraft,
},
},
{
text: TestCallsign + "'s far on 1-1. Buggydope.",
expected: &brevity.BogeyDopeRequest{
Callsign: "s far on 1 1",
Filter: brevity.Aircraft,
},
},
{
text: TestCallsign + ", copwhip11, poke it open.",
expected: &brevity.BogeyDopeRequest{
Callsign: "copwhip 1 1",
Filter: brevity.Aircraft,
},
},
{
text: TestCallsign + ", copwhip11, poke it open.",
expected: &brevity.BogeyDopeRequest{
Callsign: "copwhip 1 1",
Filter: brevity.Aircraft,
},
},
{
text: TestCallsign + " who is saying one-on-one request, Buggydope.",
expected: &brevity.BogeyDopeRequest{
Callsign: "who is saying 1 1",
Filter: brevity.Aircraft,
},
},
{
text: TestCallsign + ", hood 1-3, BOBBYDO.",
expected: &brevity.BogeyDopeRequest{
Callsign: "hood 1 3",
Filter: brevity.Aircraft,
},
},
{
text: TestCallsign + ", CAT11 request \"BOGI\".",
expected: &brevity.BogeyDopeRequest{
Callsign: "cat 1 1",
Filter: brevity.Aircraft,
},
},
{
text: TestCallsign + ", Voodoo11, BOGUIDO, please.",
expected: &brevity.BogeyDopeRequest{
Callsign: "voodoo 1 1",
Filter: brevity.Aircraft,
},
},
{
text: TestCallsign + ", CAT1/1 \"BOGI\"",
expected: &brevity.BogeyDopeRequest{
Callsign: "cat 1 1",
Filter: brevity.Aircraft,
},
},
{
text: TestCallsign + ", hurry one, two. Bogeydome.",
expected: &brevity.BogeyDopeRequest{
Callsign: "hurry 1 2",
Filter: brevity.Aircraft,
},
},
}
runParserTestCases(t, New(TestCallsign, true), testCases, func(t *testing.T, test parserTestCase, request any) {
t.Helper()
Expand Down
1 change: 0 additions & 1 deletion pkg/parser/callsign.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ func ParsePilotCallsign(tx string) (callsign string, isValid bool) {
for token, replacement := range map[string]string{
"request": "",
"this is": "",
"on one": "11",
"want to": "12",
"tutu": "22",
"to 8": "28",
Expand Down
33 changes: 33 additions & 0 deletions pkg/parser/checkin_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package parser

import (
"testing"

"github.com/dharmab/skyeye/pkg/brevity"
"github.com/stretchr/testify/require"
)

func TestParserCheckIn(t *testing.T) {
t.Parallel()
testCases := []parserTestCase{
{
text: "anyface Baron91 checking in.",
expected: &brevity.CheckInRequest{
Callsign: "baron 9 1",
},
},
{
text: "anyface, Mako, 1-1, check in.",
expected: &brevity.CheckInRequest{
Callsign: "mako 1 1",
},
},
}

runParserTestCases(t, New(TestCallsign, true), testCases, func(t *testing.T, test parserTestCase, request any) {
t.Helper()
expected := test.expected.(*brevity.CheckInRequest)
actual := request.(*brevity.CheckInRequest)
require.Equal(t, expected.Callsign, actual.Callsign)
})
}
33 changes: 33 additions & 0 deletions pkg/parser/declare_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,39 @@ func TestParserDeclare(t *testing.T) {
IsBRAA: true,
},
},
{
text: TestCallsign + ", Thunder 1-1, declare 17631.",
expected: &brevity.DeclareRequest{
Callsign: "thunder 1 1",
Bullseye: *brevity.NewBullseye(
bearings.NewMagneticBearing(176*unit.Degree),
31*unit.NauticalMile,
),
Track: brevity.UnknownDirection,
},
},
{
text: TestCallsign + ", Thunder 1-1, declare 177.29.",
expected: &brevity.DeclareRequest{
Callsign: "thunder 1 1",
Bullseye: *brevity.NewBullseye(
bearings.NewMagneticBearing(177*unit.Degree),
29*unit.NauticalMile,
),
Track: brevity.UnknownDirection,
},
},
{
text: TestCallsign + " who is saying 11 requests declare 25545.",
expected: &brevity.DeclareRequest{
Callsign: "who is saying 1 1",
Bullseye: *brevity.NewBullseye(
bearings.NewMagneticBearing(255*unit.Degree),
45*unit.NauticalMile,
),
Track: brevity.UnknownDirection,
},
},
}
runParserTestCases(t, New(TestCallsign, true), testCases, func(t *testing.T, test parserTestCase, request any) {
t.Helper()
Expand Down
68 changes: 1 addition & 67 deletions pkg/parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,73 +48,7 @@ func TestParserSadPaths(t *testing.T) {
t,
New(TestCallsign, true),
testCases,
// Nothing more to do, since the type is already checked
func(*testing.T, parserTestCase, any) {},
)
}

func TestParserAlphaCheck(t *testing.T) {
t.Parallel()
testCases := []parserTestCase{
{
text: "ANYFACE, HORNET 1, CHECKING IN AS FRAGGED, REQUEST ALPHA CHECK DEPOT",
expected: &brevity.AlphaCheckRequest{
Callsign: "hornet 1",
},
},
{
text: "anyface intruder 11 alpha check",
expected: &brevity.AlphaCheckRequest{
Callsign: "intruder 1 1",
},
},
{
text: "anyface intruder 11, checking in as fragged, request alpha check bullseye",
expected: &brevity.AlphaCheckRequest{
Callsign: "intruder 1 1",
},
},
{
text: TestCallsign + "intruder 11 alpha check",
expected: &brevity.AlphaCheckRequest{
Callsign: "intruder 1 1",
},
},
{
text: TestCallsign + "Gunfighter 2-1, AlphaJack, Bullseye.",
expected: &brevity.AlphaCheckRequest{
Callsign: "gunfighter 2 1",
},
},
}
runParserTestCases(t, New(TestCallsign, true), testCases, func(t *testing.T, test parserTestCase, request any) {
t.Helper()
expected := test.expected.(*brevity.AlphaCheckRequest)
actual := request.(*brevity.AlphaCheckRequest)
require.Equal(t, expected.Callsign, actual.Callsign)
})
}

func TestParserCheckIn(t *testing.T) {
t.Parallel()
testCases := []parserTestCase{
{
text: "anyface Baron91 checking in.",
expected: &brevity.CheckInRequest{
Callsign: "baron 9 1",
},
},
{
text: "anyface, Mako, 1-1, check in.",
expected: &brevity.CheckInRequest{
Callsign: "mako 1 1",
},
},
}

runParserTestCases(t, New(TestCallsign, true), testCases, func(t *testing.T, test parserTestCase, request any) {
t.Helper()
expected := test.expected.(*brevity.CheckInRequest)
actual := request.(*brevity.CheckInRequest)
require.Equal(t, expected.Callsign, actual.Callsign)
})
}
6 changes: 6 additions & 0 deletions pkg/parser/radiocheck_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ func TestParserRadioCheck(t *testing.T) {
Callsign: "heaven",
},
},
{
text: TestCallsign + ", call me '1-2', DRAVIA CHECK.",
expected: &brevity.RadioCheckRequest{
Callsign: "call me 1 2",
},
},
}
runParserTestCases(t, New(TestCallsign, true), testCases, func(t *testing.T, test parserTestCase, request any) {
t.Helper()
Expand Down
1 change: 1 addition & 0 deletions pkg/parser/replacements.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ var replacementLUT = map[string]string{
"bobbydo": bogeyDope,
"bobido": bogeyDope,
"boby dope": bogeyDope,
"dravia check": radioCheck,
"bobydo": bogeyDope,
"bog it": bogeyDope,
"bogado": bogeyDope,
Expand Down
11 changes: 11 additions & 0 deletions pkg/parser/snaplock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,17 @@ func TestParserSnaplock(t *testing.T) {
),
},
},
{
text: TestCallsign + " Cat 1 1 Snaplock 0608-9.",
expected: &brevity.SnaplockRequest{
Callsign: "cat 1 1",
BRA: brevity.NewBRA(
bearings.NewMagneticBearing(60*unit.Degree),
8*unit.NauticalMile,
9000*unit.Foot,
),
},
},
}
runParserTestCases(t, New(TestCallsign, true), testCases, func(t *testing.T, test parserTestCase, request any) {
t.Helper()
Expand Down

0 comments on commit b735096

Please sign in to comment.