Claude/add unit tests#82
Merged
Merged
Conversation
Lifts overall coverage from 31% to 42% by adding tests for previously untested modules and edge cases. Reuses the existing redis_mock and postgres_mock fixtures and the generate_messages TRAPI helpers. New test files: - tests/unit/test_shared_utils.py: combine_unique_dicts, merge_kgraph, is_support_edge, recursive support-graph traversal, validate_message, filter_kgraph_orphans, wrap_up_task, handle_task_failure - tests/unit/test_trapi_to_networkx.py: full matrix of trapi_kg_to_nx modes (multigraph/collapsed, directed/undirected, weight derivation and aggregation, transform fallback, input format variants) - tests/unit/test_db.py: encode/decode codecs, sync get/save variants, save_logs/get_logs roundtrip, retry-on-failure for save_message - tests/unit/test_broker.py: consumer group create idempotency, add/get/ack roundtrip, lock acquire/release with token compare - tests/unit/test_logger.py: ReasonerLogEntryFormatter, QueryLogger handler ordering, maxlen, kubernetes vs local config selection - tests/unit/test_filter_analyses_top_n.py: cap behavior, default, empty results - tests/unit/aragorn/test_aragorn_examine_query.py: all examine_query branches (lookup, infer, pathfinder, mixed errors) plus workflow selection on the aragorn entrypoint - tests/unit/aragorn/test_aragorn_lookup_helpers.py: examine_query, get_infer_parameters, get_rule_key, expand_aragorn_query, plus pure-lookup and gandalf branches of aragorn_lookup - tests/unit/test_merge_message_helpers.py: get_edgeset, create_aux_graph, add_knowledge_edge, _normalize_query, queries_equivalent, has_unique_nodes, filter_repeated_nodes, get_promiscuous_qnodes, remove_promiscuous_knode_results, get_answer_node, group_results_by_qnode, merge_messages (lookup/creative/pathfinder) - tests/unit/test_finish_query_edge_cases.py: missing query state, ERROR status propagation, callback retries, logs attachment https://claude.ai/code/session_01Bk7CnUHNrYjz6VeUS2JMwX
Lifts coverage from 42% to 50% with 60 new tests across 6 files. Covers workers that previously had no test coverage at all. Also adds workers/sipr/__init__.py: the directory was missing one, which prevented native package import. Source layout otherwise unchanged. New test files: - tests/unit/test_aragorn_pathfinder.py: shadowfax happy path, three-hop query construction, validation errors (two pinned nodes, single constraint, single intermediate category), gandalf parameter passthrough - tests/unit/test_bte.py: examine_query branches, bte() workflow selection, pathfinder rejection, preexisting-workflow preservation - tests/unit/test_bte_lookup.py: examine_query, get_params (qualifier extraction), match_templates against the real template_groups.json, fill_templates substitution in both subject/object directions, expand_bte_query, AsyncResponse, plus pure-lookup and pathfinder-rejection branches of bte_lookup - tests/unit/test_sipr.py: write_trapi (per-hop categories), distribute_weights (PageRank with/without seed), get_nodes (kgraph filtering, HP curie exclusion), sipr() entrypoint set-input vs not - tests/unit/test_sipr_graph_filterer.py: remove_isolated, add_hub_node, filter_graph_by_weight (above/below cutoff, missing weight, attribute preservation, post-filter orphan removal), apply_to_graph - tests/unit/test_inject_shepherd_arax_provenance.py: source injection on every edge, idempotency, defensive paths for malformed inputs https://claude.ai/code/session_01Bk7CnUHNrYjz6VeUS2JMwX
Lifts coverage from 50% to 56% with 79 new tests across 4 files. Focuses on the postgres-backed db helpers (which had no tests at all), the pure scoring helpers in aragorn_score, and the process_task wrappers across the simple workers. New test files: - tests/unit/test_db_postgres.py: add_query (redis + postgres), add_callback_id / remove_callback_id (with OperationalError retry), get_running_callbacks, cleanup_callbacks, get_callback_query_id, get_query_state, set_query_completed, initialize_db / shutdown_db, check_connection - tests/unit/aragorn/test_aragorn_score_helpers.py: get_base_weight, get_source_weight, get_source_sigmoid (centered, saturated, unknown), get_profile (parametrized over all four profiles + unknown fallback), kirchhoff (unit resistor + 3-node line + invalid index), and get_edge_support_kg (recursion through support graphs, missing aux, missing edges, accumulator threading) - tests/unit/test_process_task_wrappers.py: 22 tests for the process_task happy/cancellation/failure paths across 10 workers (filter_kgraph_orphans, filter_results_top_n, filter_analyses_top_n, sort_results_score, example_ara, example_score, example_lookup, aragorn, aragorn_pathfinder, bte) plus wrap_up_task swallow check - tests/unit/test_misc_branch_coverage.py: targeted branches in merge_kgraph (overlapping edge merge), validate_message, aragorn_omnicorp helpers (create_log_entry, add_node_pmid_counts default 0, add_shared_pmid_counts existing-OMNICORP-aux reuse, generate_curie_pairs setnode pairings), finish_query.process_task (success + failure + ack-failure + cancellation) https://claude.ai/code/session_01Bk7CnUHNrYjz6VeUS2JMwX
Lifts coverage from 56% to 59% with 47 new tests across 2 files. Both targeted modules (aragorn_score and bte_lookup) reach 89% coverage. aragorn_score went from 70% to 89%; bte_lookup went from 69% to 89%. New test files: - tests/unit/aragorn/test_aragorn_score_ranker.py (31 tests): Ranker.__init__ profile selection, probes() (probe node selection from qgraph connectivity), get_omnicorp_node_pubs (cache, alternate attribute names, unparseable values, missing nodes), get_edge_values (publications splitting by pipe/comma/string, evidence_count, p_value extraction with list/string/numeric, affinity, confidence, literature_cooccurrence with omnicorp predicate), get_rgraph (per-analysis graph construction, support graph inclusion, missing edges), graph_laplacian (laplacian shape, zero-row pruning protecting probes), score (jaccard_like transform), rank (sorted output) - tests/unit/test_bte_lookup_branches.py (16 tests): run_async_lookup (200/non-200/exception, callback URL injection), bte_lookup inferred fanout (expand_bte_query call count, failed callback removal, exception logging), polling loop branches (in-progress drain, db error retry, timeout cleanup), default submitter injection, process_task (happy/failure/cancellation/wrap_up_failure paths) https://claude.ai/code/session_01Bk7CnUHNrYjz6VeUS2JMwX
Codecov Report✅ All modified and coverable lines are covered by tests. Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.