@@ -6327,3 +6327,96 @@ mod tests {
63276327 assert ! ( err. to_string( ) . contains( "Unknown comparison type" ) ) ;
63286328 }
63296329}
6330+
6331+ #[ cfg( test) ]
6332+ mod next_commands_validity {
6333+ use super :: Cli ;
6334+ use clap:: Parser ;
6335+
6336+ fn parse_cmd ( cmd : & str ) -> Vec < String > {
6337+ shlex:: split ( cmd) . unwrap_or_else ( || panic ! ( "shlex failed on: {cmd}" ) )
6338+ }
6339+
6340+ fn assert_parses ( cmd : & str ) {
6341+ Cli :: try_parse_from ( parse_cmd ( cmd) )
6342+ . unwrap_or_else ( |e| panic ! ( "failed to parse '{cmd}': {e}" ) ) ;
6343+ }
6344+
6345+ #[ test]
6346+ fn gene_next_commands_parse ( ) {
6347+ assert_parses ( "biomcp search variant -g BRAF" ) ;
6348+ assert_parses ( "biomcp search article -g BRAF" ) ;
6349+ assert_parses ( "biomcp search drug --target BRAF" ) ;
6350+ assert_parses ( "biomcp gene trials BRAF" ) ;
6351+ }
6352+
6353+ #[ test]
6354+ fn variant_next_commands_parse ( ) {
6355+ assert_parses ( "biomcp get gene BRAF" ) ;
6356+ assert_parses ( "biomcp search drug --target BRAF" ) ;
6357+ assert_parses ( r#"biomcp variant trials "rs113488022""# ) ;
6358+ assert_parses ( r#"biomcp variant articles "rs113488022""# ) ;
6359+ assert_parses ( r#"biomcp variant oncokb "rs113488022""# ) ;
6360+ }
6361+
6362+ #[ test]
6363+ fn article_next_commands_parse ( ) {
6364+ assert_parses ( "biomcp get gene EGFR" ) ;
6365+ assert_parses ( "biomcp search disease --query melanoma" ) ;
6366+ assert_parses ( "biomcp get drug osimertinib" ) ;
6367+ assert_parses ( "biomcp article entities 12345" ) ;
6368+ }
6369+
6370+ #[ test]
6371+ fn trial_next_commands_parse ( ) {
6372+ assert_parses ( "biomcp search disease --query melanoma" ) ;
6373+ assert_parses ( "biomcp search article -d melanoma" ) ;
6374+ assert_parses ( "biomcp search trial -c melanoma" ) ;
6375+ assert_parses ( "biomcp get drug dabrafenib" ) ;
6376+ assert_parses ( "biomcp drug trials dabrafenib" ) ;
6377+ }
6378+
6379+ #[ test]
6380+ fn disease_next_commands_parse ( ) {
6381+ assert_parses ( "biomcp search trial -c melanoma" ) ;
6382+ assert_parses ( "biomcp search article -d melanoma" ) ;
6383+ assert_parses ( "biomcp search drug melanoma" ) ;
6384+ }
6385+
6386+ #[ test]
6387+ fn pgx_next_commands_parse ( ) {
6388+ assert_parses ( "biomcp search pgx -g CYP2D6" ) ;
6389+ assert_parses ( "biomcp search pgx -d warfarin" ) ;
6390+ }
6391+
6392+ #[ test]
6393+ fn drug_next_commands_parse ( ) {
6394+ assert_parses ( "biomcp drug trials osimertinib" ) ;
6395+ assert_parses ( "biomcp drug adverse-events osimertinib" ) ;
6396+ assert_parses ( "biomcp get gene EGFR" ) ;
6397+ }
6398+
6399+ #[ test]
6400+ fn pathway_next_commands_parse ( ) {
6401+ assert_parses ( "biomcp pathway drugs R-HSA-5673001" ) ;
6402+ }
6403+
6404+ #[ test]
6405+ fn protein_next_commands_parse ( ) {
6406+ assert_parses ( "biomcp get protein P00533 structures" ) ;
6407+ assert_parses ( "biomcp get gene EGFR" ) ;
6408+ }
6409+
6410+ #[ test]
6411+ fn adverse_event_next_commands_parse ( ) {
6412+ assert_parses ( "biomcp get drug osimertinib" ) ;
6413+ assert_parses ( "biomcp drug adverse-events osimertinib" ) ;
6414+ assert_parses ( "biomcp drug trials osimertinib" ) ;
6415+ }
6416+
6417+ #[ test]
6418+ fn device_event_next_commands_parse ( ) {
6419+ assert_parses ( "biomcp search adverse-event --type device --device HeartValve" ) ;
6420+ assert_parses ( r#"biomcp search adverse-event --type recall --classification "Class I""# ) ;
6421+ }
6422+ }
0 commit comments