def test_cc_graph(cc_graph):
    assert business_trip(cc_graph, [
        'Metroville',
        'Pandora',
    ]) == 'True, $82'
    assert business_trip(
        cc_graph, ['Metroville', 'Pandora', 'Metroville']) == 'True, $164'
    assert business_trip(
        cc_graph, ['Arendelle', 'Monstropolis', 'Naboo']) == 'True, $115'
    assert business_trip(cc_graph, ['Naboo', 'Pandora']) == 'False, $0'
    assert business_trip(cc_graph,
                         ['Narnia', 'Arendelle', 'Naboo']) == 'False, $0'
Beispiel #2
0
def test_graph_business_trip():
    graph = Graph()

    pandora_city = graph.add_node("Pandora")
    arendelle_city = graph.add_node("Arendelle")
    metroville_city = graph.add_node("Metroville")
    monstropolis_city = graph.add_node("Monstropolis")
    narnia_city = graph.add_node("Narnia")
    naboo_city = graph.add_node("Naboo")

    graph.add_edge(pandora_city, arendelle_city, 150)
    graph.add_edge(pandora_city, metroville_city, 82)
    graph.add_edge(arendelle_city, metroville_city, 99)
    graph.add_edge(arendelle_city, monstropolis_city, 42)
    graph.add_edge(metroville_city, monstropolis_city, 105)
    graph.add_edge(metroville_city, narnia_city, 37)
    graph.add_edge(metroville_city, naboo_city, 26)
    graph.add_edge(monstropolis_city, naboo_city, 73)
    graph.add_edge(narnia_city, naboo_city, 250)


    actual1 = business_trip(graph, [narnia_city, arendelle_city, naboo_city])
    expected1 = (False, 0)
    assert actual1 == expected1

    actual2 = business_trip(graph, [metroville_city, pandora_city])
    expected2 = (True, 82)
    assert actual2 == expected2

    actual3 = business_trip(graph, [arendelle_city, monstropolis_city, naboo_city])
    expected3 = (True, 115)
    assert actual3 == expected3

    actual4 = business_trip(graph, [naboo_city, pandora_city])
    expected4 = (False, 0)
    assert actual4 == expected4 
def test_base_graph(base_graph):
    assert business_trip(base_graph, ['a', 'b']) == 'True, $150'
    assert business_trip(base_graph, ['a', 'b', 'c']) == 'True, $350'
    assert business_trip(base_graph, ['a', 'c']) == 'False, $0'
    assert business_trip(base_graph, ['a', 'a']) == 'False, $0'
    assert business_trip(base_graph, ['a']) == 'False, $0'
def test_edge_case(adding):
    assert business_trip(adding,
                         ['Narnia', 'Naboo', 'Arendelle']) == [False, '$0']
def test_expected_failure(adding):
    assert business_trip(adding,
                         ['Narnia', 'Arendelle', 'Naboo']) == [False, '$0']
def test_happy_path(adding):
    assert business_trip(adding, ['Metroville', 'Pandora']) == [True, '$82']