From a3aa4139e9deb670406b26df5e2e0892168f5221 Mon Sep 17 00:00:00 2001 From: Joel Natividad <1980690+jqnatividad@users.noreply.github.com> Date: Sat, 27 Jan 2024 09:18:36 -0500 Subject: [PATCH] `tests`: add `apply operations gender_guess` test --- tests/test_apply.rs | 55 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/tests/test_apply.rs b/tests/test_apply.rs index 11467fc33..47ee275c0 100644 --- a/tests/test_apply.rs +++ b/tests/test_apply.rs @@ -47,6 +47,61 @@ fn apply_ops_upper() { assert_eq!(got, expected); } +#[test] +fn apply_ops_gender_guess() { + let wrk = Workdir::new("apply"); + wrk.create( + "data.csv", + vec![ + svec!["name"], + svec!["Peter"], + svec!["Michael"], + svec!["Joel"], + svec!["Hussein"], + svec!["Ian"], + svec!["Enrique"], + svec!["Ana"], + svec!["Olivia"], + svec!["Mackenzie"], + svec!["Adair"], + svec!["Aaf"], + svec!["Voldemort"], + svec!["Sami"], + svec!["Minhaj"], + svec!["Abdurrahman"], + svec!["Abbe"], + ], + ); + let mut cmd = wrk.command("apply"); + cmd.arg("operations") + .arg("gender_guess") + .arg("name") + .args(["--new-column", "Gender"]) + .arg("data.csv"); + + let got: Vec> = wrk.read_stdout(&mut cmd); + let expected = vec![ + svec!["name", "Gender"], + svec!["Peter", "Male"], + svec!["Michael", "Male"], + svec!["Joel", "Male"], + svec!["Hussein", "Male"], + svec!["Ian", "Male"], + svec!["Enrique", "Male"], + svec!["Ana", "Female"], + svec!["Olivia", "Female"], + svec!["Mackenzie", "NotSure"], + svec!["Adair", "MayBeMale"], + svec!["Aaf", "MayBeFemale"], + svec!["Voldemort", "NotFound"], + svec!["Sami", "Male"], + svec!["Minhaj", "NotFound"], + svec!["Abdurrahman", "Male"], + svec!["Abbe", "NotSure"], + ]; + assert_eq!(got, expected); +} + #[test] fn apply_ops_escape() { let wrk = Workdir::new("apply");