def test_programs_of_taxons(): dbf = ProgramFilter(db) taxons = {"X/S/M/L/R/D/A", "X/S/M/L/R/D", "non_existing_taxon"} programs = dbf.programs_of_taxons(taxons, follow=False) print(sorted(programs)) for (db_program, db_program_data) in db["programs"].items(): if taxons.intersection(db_program_data["taxons"]): assert db_program in programs else: assert db_program not in programs
def test_programs_of_taxons(): dbf = ProgramFilter(db) taxons = {"variable/assignment/single"} # The taxon "variable/assignment/single" is featured by assignment.py and collatz_print.py. # This corresponds to follow=False. It is indirectly featured by fizzbuzz.py (which imports # collatz_print.py) and by is_even.py (which imports fizzbuzz.py). Their addition corresponds # to follow=True. programs = dbf.programs_of_taxons(taxons, follow=False) print(set(programs)) assert set(programs) == {"assignment.py", "collatz_print.py"} programs = dbf.programs_of_taxons(taxons, follow=True) print(set(programs)) assert set(programs) == { "assignment.py", "collatz_print.py", "fizzbuzz.py", "is_even.py", }