-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
435 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pub fn new_request_to_test() { | ||
todo | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,178 @@ | ||
import gleam/option.{None, Some} | ||
import gleam/set | ||
import gleeunit/should | ||
import structs | ||
import tatoeba/search/sentence as sentence_options | ||
import utils | ||
|
||
pub fn new_word_count_options_test() { | ||
let word_count_options = sentence_options.new_word_count_options() | ||
|
||
word_count_options.at_least |> should.equal(None) | ||
word_count_options.at_most |> should.equal(None) | ||
} | ||
|
||
pub fn set_at_least_test() { | ||
let word_count_options = | ||
sentence_options.new_word_count_options() | ||
|> sentence_options.set_at_least(5) | ||
|
||
word_count_options.at_least |> should.equal(Some(5)) | ||
} | ||
|
||
pub fn set_at_most_test() { | ||
let word_count_options = | ||
sentence_options.new_word_count_options() | ||
|> sentence_options.set_at_most(10) | ||
|
||
word_count_options.at_most |> should.equal(Some(10)) | ||
} | ||
|
||
pub fn word_count_options_to_query_parameters_test() { | ||
structs.word_count_options() | ||
|> sentence_options.word_count_options_to_query_parameters() | ||
|> utils.sort_parameters() | ||
|> should.equal( | ||
[#("word_count_min", "10"), #("word_count_max", "20")] | ||
|> utils.sort_parameters(), | ||
) | ||
} | ||
|
||
pub fn new_test() { | ||
let sentence_options = sentence_options.new() | ||
|
||
sentence_options.query |> should.equal(None) | ||
sentence_options.source_language |> should.equal(None) | ||
sentence_options.target_language |> should.equal(None) | ||
sentence_options.word_count_options | ||
|> should.equal(sentence_options.new_word_count_options()) | ||
sentence_options.owner_id |> should.equal(None) | ||
sentence_options.is_orphan |> should.equal(None) | ||
sentence_options.is_unapproved |> should.equal(None) | ||
sentence_options.has_audio |> should.equal(None) | ||
sentence_options.claimed_native |> should.equal(None) | ||
sentence_options.tags |> should.equal(set.new()) | ||
sentence_options.list_id |> should.equal(None) | ||
} | ||
|
||
pub fn set_query_test() { | ||
let sentence_options = | ||
sentence_options.new() | ||
|> sentence_options.set_query("drepequamvisacircation") | ||
|
||
sentence_options.query |> should.equal(Some("drepequamvisacircation")) | ||
} | ||
|
||
pub fn set_source_language_test() { | ||
let sentence_options = | ||
sentence_options.new() | ||
|> sentence_options.set_source_language("ron") | ||
|
||
sentence_options.source_language |> should.equal(Some("ron")) | ||
} | ||
|
||
pub fn set_target_language_test() { | ||
let sentence_options = | ||
sentence_options.new() | ||
|> sentence_options.set_target_language("hye") | ||
|
||
sentence_options.target_language |> should.equal(Some("hye")) | ||
} | ||
|
||
pub fn set_word_count_options_test() { | ||
let word_count_options = | ||
sentence_options.new_word_count_options() | ||
|> sentence_options.set_at_least(5) | ||
let sentence_options = | ||
sentence_options.new() | ||
|> sentence_options.set_word_count_options(word_count_options) | ||
|
||
sentence_options.word_count_options |> should.equal(word_count_options) | ||
} | ||
|
||
pub fn set_owner_id_test() { | ||
let sentence_options = | ||
sentence_options.new() | ||
|> sentence_options.set_owner_id(5) | ||
|
||
sentence_options.owner_id |> should.equal(Some(5)) | ||
} | ||
|
||
pub fn set_is_orphan_test() { | ||
let sentence_options = | ||
sentence_options.new() | ||
|> sentence_options.set_is_orphan(True) | ||
|
||
sentence_options.is_orphan |> should.equal(Some(True)) | ||
} | ||
|
||
pub fn set_is_unapproved_test() { | ||
let sentence_options = | ||
sentence_options.new() | ||
|> sentence_options.set_is_unapproved(True) | ||
|
||
sentence_options.is_unapproved |> should.equal(Some(True)) | ||
} | ||
|
||
pub fn set_has_audio_test() { | ||
let sentence_options = | ||
sentence_options.new() | ||
|> sentence_options.set_has_audio(True) | ||
|
||
sentence_options.has_audio |> should.equal(Some(True)) | ||
} | ||
|
||
pub fn set_claimed_native_test() { | ||
let sentence_options = | ||
sentence_options.new() | ||
|> sentence_options.set_claimed_native(True) | ||
|
||
sentence_options.claimed_native |> should.equal(Some(True)) | ||
} | ||
|
||
pub fn set_tag_test() { | ||
let sentence_options = | ||
sentence_options.new() | ||
|> sentence_options.set_tag("Fungi") | ||
|
||
sentence_options.tags |> should.equal(set.from_list(["Fungi"])) | ||
} | ||
|
||
pub fn set_tags_test() { | ||
let sentence_options = | ||
sentence_options.new() | ||
|> sentence_options.set_tags(set.from_list(["Animals", "Plants"])) | ||
|
||
sentence_options.tags |> should.equal(set.from_list(["Animals", "Plants"])) | ||
} | ||
|
||
pub fn set_list_id_test() { | ||
let sentence_options = | ||
sentence_options.new() | ||
|> sentence_options.set_list_id(5) | ||
|
||
sentence_options.list_id |> should.equal(Some(5)) | ||
} | ||
|
||
pub fn to_query_parameters_test() { | ||
structs.sentence_options() | ||
|> sentence_options.to_query_parameters() | ||
|> utils.sort_parameters() | ||
|> should.equal( | ||
[ | ||
#("query", "betwixt"), | ||
#("from", "eng"), | ||
#("to", "ron"), | ||
#("user", "7031"), | ||
#("orphans", "yes"), | ||
#("unapproved", "no"), | ||
#("has_audio", "no"), | ||
#("native", "yes"), | ||
#("tags", "MyTag,YourTag,TheirTag"), | ||
#("list", "123"), | ||
#("word_count_min", "10"), | ||
#("word_count_max", "20"), | ||
] | ||
|> utils.sort_parameters(), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import gleam/option.{None, Some} | ||
import gleeunit/should | ||
import structs | ||
import tatoeba/search/translation as translation_options | ||
|
||
pub fn new() { | ||
let translation_options = translation_options.new() | ||
|
||
translation_options.filter_strategy |> should.equal(translation_options.Limit) | ||
translation_options.language |> should.equal(None) | ||
translation_options.link |> should.equal(None) | ||
translation_options.owner_id |> should.equal(None) | ||
translation_options.is_orphan |> should.equal(None) | ||
translation_options.is_unapproved |> should.equal(None) | ||
translation_options.has_audio |> should.equal(None) | ||
} | ||
|
||
pub fn set_filter_strategy() { | ||
let translation_options = | ||
translation_options.new() | ||
|> translation_options.set_filter_strategy(translation_options.Limit) | ||
|
||
translation_options.filter_strategy |> should.equal(translation_options.Limit) | ||
} | ||
|
||
pub fn set_language() { | ||
let translation_options = | ||
translation_options.new() | ||
|> translation_options.set_language("ron") | ||
|
||
translation_options.language |> should.equal(Some("ron")) | ||
} | ||
|
||
pub fn set_link() { | ||
let translation_options = | ||
translation_options.new() | ||
|> translation_options.set_link(translation_options.Direct) | ||
|
||
translation_options.link |> should.equal(Some(translation_options.Direct)) | ||
} | ||
|
||
pub fn set_owner_id() { | ||
let translation_options = | ||
translation_options.new() | ||
|> translation_options.set_owner_id(5) | ||
|
||
translation_options.owner_id |> should.equal(Some(5)) | ||
} | ||
|
||
pub fn set_is_orphan() { | ||
let translation_options = | ||
translation_options.new() | ||
|> translation_options.set_is_orphan(True) | ||
|
||
translation_options.link |> should.equal(Some(translation_options.Direct)) | ||
} | ||
|
||
pub fn set_is_unapproved() { | ||
let translation_options = | ||
translation_options.new() | ||
|> translation_options.set_is_unapproved(True) | ||
|
||
translation_options.is_unapproved | ||
|> should.equal(Some(True)) | ||
} | ||
|
||
pub fn set_has_audio() { | ||
let translation_options = | ||
translation_options.new() | ||
|> translation_options.set_has_audio(True) | ||
|
||
translation_options.has_audio | ||
|> should.equal(Some(True)) | ||
} | ||
|
||
pub fn to_query_parameters() { | ||
structs.translation_options() | ||
|> translation_options.to_query_parameters() | ||
|> should.equal([ | ||
#("trans_filter", "limit"), | ||
#("trans_to", "ron"), | ||
#("trans_link", "direct"), | ||
#("trans_user", "123"), | ||
#("trans_orphan", "yes"), | ||
#("trans_unapproved", "no"), | ||
#("trans_has_audio", "yes"), | ||
]) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import gleam/option.{None, Some} | ||
import gleeunit/should | ||
import tatoeba/search/utils | ||
|
||
pub fn exclude_missing_test() { | ||
[ | ||
#("key-with-present-value", Some("present")), | ||
#("key-with-missing-value", None), | ||
] | ||
|> utils.select_present() | ||
|> should.equal([#("key-with-present-value", "present")]) | ||
} | ||
|
||
pub fn bool_to_yes_no_test() { | ||
True |> utils.bool_to_yes_no() |> should.equal("yes") | ||
False |> utils.bool_to_yes_no() |> should.equal("no") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import gleam/list | ||
import gleam/option.{None, Some} | ||
import gleeunit/should | ||
import structs | ||
import tatoeba/search | ||
import tatoeba/search/sentence | ||
import tatoeba/search/translation | ||
|
||
pub fn sort_strategy_to_string_test() { | ||
[ | ||
search.Relevance, | ||
search.FewestWordsFirst, | ||
search.LastCreatedFirst, | ||
search.LastModifiedFirst, | ||
search.Random, | ||
] | ||
|> list.map(search.sort_strategy_to_string) | ||
|> should.equal(["relevance", "words", "created", "modified", "random"]) | ||
} | ||
|
||
pub fn new_test() { | ||
let search = search.new() | ||
|
||
search.sentence_options |> should.equal(sentence.new()) | ||
search.translation_options |> should.equal(translation.new()) | ||
search.sort_strategy |> should.equal(None) | ||
search.reverse_sort |> should.equal(None) | ||
} | ||
|
||
pub fn set_sentence_options_test() { | ||
let sentence_options = | ||
sentence.new() | ||
// Eastern Armenian | ||
|> sentence.set_source_language("hye") | ||
let search = | ||
search.new() | ||
|> search.set_sentence_options(sentence_options) | ||
|
||
search.sentence_options |> should.equal(sentence_options) | ||
} | ||
|
||
pub fn set_translation_options_test() { | ||
let translation_options = | ||
translation.new() | ||
// Romanian | ||
|> translation.set_language("ron") | ||
let search = | ||
search.new() | ||
|> search.set_translation_options(translation_options) | ||
|
||
search.translation_options |> should.equal(translation_options) | ||
} | ||
|
||
pub fn set_sort_strategy_test() { | ||
let search = search.new() |> search.set_sort_strategy(search.Relevance) | ||
|
||
search.sort_strategy |> should.equal(Some(search.Relevance)) | ||
} | ||
|
||
pub fn set_reverse_sort_test() { | ||
let search = search.new() |> search.set_reverse_sort(True) | ||
|
||
search.reverse_sort |> should.equal(Some(True)) | ||
} | ||
|
||
pub fn to_query_parameters_test() { | ||
structs.search_options() | ||
|> search.to_query_parameters() | ||
|
||
todo | ||
} | ||
|
||
pub fn run_test() { | ||
todo | ||
} |
Oops, something went wrong.