chore(tests): remove debug tests that depend on local file paths
Remove TestConvertHessBook and TestDebugHess (both referenced a non-existent Hess EPUB at an absolute local path) and TestConvertCPByTextSearch (referenced a Crime and Punishment EPUB in the local uploads directory). These were development-time debug tests that only worked on the author's machine. All CFI/KEPUB conversion behavior is already covered by the proper fixture-based tests (TestKEPUBRoundTrip, TestKEPUBConvertKEPUBToStandard, TestKEPUBConvertWithEmElements, etc.) which use createTestEPUB and createTestKEPUB helpers.
This commit is contained in:
@@ -162,51 +162,6 @@ func TestConvertCrimeAndPunishmentFragmentID(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestConvertHessBook(t *testing.T) {
|
|
||||||
epubPath := "/home/nymusicman/Code/bookhoard/William L Hess/Crushing the Great Serpent_ Did God (42)/Crushing the Great Serpent_ Did - William L Hess.epub"
|
|
||||||
c := NewCFIConverter(epubPath)
|
|
||||||
|
|
||||||
xp := "/body/DocFragment[5]/body/div[3]/p[28]/text().500"
|
|
||||||
result, err := c.ConvertCREToStandard(xp, 0.08, "")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("ConvertCREToStandard error: %v", err)
|
|
||||||
}
|
|
||||||
t.Logf("Input: %s", xp)
|
|
||||||
t.Logf("EPUBCFI: %s", result.EPUBCFI)
|
|
||||||
t.Logf("Href: %s", result.Href)
|
|
||||||
t.Logf("Precision: %s", result.Precision)
|
|
||||||
t.Logf("Percentage: %.4f", result.Percentage)
|
|
||||||
|
|
||||||
if result.Precision == "percentage" {
|
|
||||||
t.Error("expected better than percentage precision")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestConvertCPByTextSearch(t *testing.T) {
|
|
||||||
epubPath := "/home/nymusicman/Code/bookhoard/uploads/Ebooks/Fyodor Dostoyevsky/Crime and Punishment (103)/Crime and Punishment - Fyodor Dostoyevsky.epub"
|
|
||||||
c := NewCFIConverter(epubPath)
|
|
||||||
|
|
||||||
xp := "/body/DocFragment[6]/body/div/p[47]/text().1"
|
|
||||||
contextText := "Raskolnikov was not used to crowds, and, as we said before, he avoided society of every sort, more especially of l"
|
|
||||||
result, err := c.ConvertCREToStandard(xp, 0.0579, contextText)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("ConvertCREToStandard error: %v", err)
|
|
||||||
}
|
|
||||||
t.Logf("Input: %s", xp)
|
|
||||||
t.Logf("ContextText: %s", contextText)
|
|
||||||
t.Logf("EPUBCFI: %s", result.EPUBCFI)
|
|
||||||
t.Logf("Href: %s", result.Href)
|
|
||||||
t.Logf("Precision: %s", result.Precision)
|
|
||||||
t.Logf("Percentage: %.4f", result.Percentage)
|
|
||||||
|
|
||||||
if result.Precision != "exact" {
|
|
||||||
t.Errorf("expected exact precision, got %s", result.Precision)
|
|
||||||
}
|
|
||||||
if result.EPUBCFI == "" {
|
|
||||||
t.Error("expected non-empty EPUBCFI")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestParseEPUBCFI(t *testing.T) {
|
func TestParseEPUBCFI(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
input string
|
input string
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
package sync
|
|
||||||
|
|
||||||
import "testing"
|
|
||||||
|
|
||||||
func TestDebugHess(t *testing.T) {
|
|
||||||
epubPath := "/home/nymusicman/Code/bookhoard/William L Hess/Crushing the Great Serpent_ Did God (42)/Crushing the Great Serpent_ Did - William L Hess.epub"
|
|
||||||
c := NewCFIConverter(epubPath)
|
|
||||||
|
|
||||||
xp, err := ParseCREXPointer("/body/DocFragment[5]/body/div[3]/p[28]/text().500")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
t.Logf("FragmentIndex: %d, CharOffset: %d", xp.FragmentIndex, xp.CharOffset)
|
|
||||||
|
|
||||||
doc, href, err := c.getContentDoc(xp.FragmentIndex)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("getContentDoc error: %v", err)
|
|
||||||
}
|
|
||||||
t.Logf("href: %s", href)
|
|
||||||
|
|
||||||
body := findBody(doc)
|
|
||||||
if body == nil {
|
|
||||||
t.Fatal("no body")
|
|
||||||
}
|
|
||||||
|
|
||||||
totalChars := countTextChars(body)
|
|
||||||
t.Logf("total chars in doc: %d", totalChars)
|
|
||||||
|
|
||||||
target, foundOffset := findNodeAtCharOffset(body, 500)
|
|
||||||
if target == nil {
|
|
||||||
t.Fatal("target is nil")
|
|
||||||
}
|
|
||||||
t.Logf("foundOffset: %d target: <%s>", foundOffset, target.Data)
|
|
||||||
|
|
||||||
cfi, err := buildCFI(5, target, 0)
|
|
||||||
t.Logf("cfi: %q err: %v", cfi, err)
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user