def test_execute(_mock_call_insights):
    """Test the function execute."""
    f = open("tests/data/stack_aggregator_execute_input.json", "r")
    payload = json.loads(f.read())

    r = RecommendationTask()
    out = r.execute(arguments=payload, persist=False)
    assert out['recommendation'] == "success"
    r = RecommendationTask()
    out = r.execute(arguments=payload, check_license=True, persist=False)
    assert out['recommendation'] == "success"

    out = r.execute(arguments=payload, persist=True)
    assert out['recommendation'] == "database error"
Example #2
0
def test_execute(_mock_call_insights, _mock_db):
    """Test the function execute."""
    with open("tests/data/stack_aggregator_execute_input.json", "r") as f:
        payload = json.load(f)

    r = RecommendationTask()
    out = r.execute(arguments=payload, persist=False)
    assert out['recommendation'] == "success"
    r = RecommendationTask()
    out = r.execute(arguments=payload, check_license=True, persist=False)
    assert out['recommendation'] == "success"

    out = r.execute(arguments=payload, persist=True)
    _mock_db.assert_called_once()
Example #3
0
def test_execute_with_insights(_mock1, _mock2, _mock3):
    """Test the function execute."""
    with open("tests/data/stack_aggregator_execute_input.json", "r") as f:
        payload = json.load(f)

    r = RecommendationTask()
    out = r.execute(arguments=payload, persist=False, check_license=False)

    assert out['recommendation'] == "success"
def test_execute_both_resolved_type(_mock_call_insights, _mock_db):
    """Test the function execute."""
    with open("tests/data/stack_aggregator_combined_input.json", "r") as f:
        payload = json.load(f)

    r = RecommendationTask()
    out = r.execute(arguments=payload, persist=False)
    assert out['recommendation'] == "success"
    assert len(out['result']['recommendations']) == 3
    file_names_expecetd = ["/home/JohnDoe1", "/home/JohnDoe2", "/home/JohnDoe3"]
    file_names_received = [reco["manifest_file_path"] for reco in out['result']['recommendations']]
    assert file_names_received == file_names_expecetd
    r = RecommendationTask()
    out = r.execute(arguments=payload, check_license=True, persist=False)
    assert out['recommendation'] == "success"

    out = r.execute(arguments=payload, persist=True)
    _mock_db.assert_called_once()
def test_execute_empty_resolved(_mock_call_insights):
    """Test the function execute."""
    with open("tests/data/stack_aggregator_empty_resolved.json", "r") as f:
        payload = json.loads(f.read())

    r = RecommendationTask()
    out = r.execute(arguments=payload, persist=False)

    assert out['recommendation'] == "success"
    assert not out["result"]["recommendations"][0]["companion"]
    assert not out["result"]["recommendations"][0]["alternate"]
    assert not out["result"]["recommendations"][0]["usage_outliers"]

    r = RecommendationTask()
    out = r.execute(arguments=payload, check_license=True, persist=False)
    assert out['recommendation'] == "success"

    out = r.execute(arguments=payload, persist=True)
    assert out['recommendation'] == "database error"