Example #1
0
def solve_and_print(request, remote_repositories, installed_repository,
                    print_ids):
    pool = Pool(remote_repositories)
    pool.add_repository(installed_repository)

    solver = Solver(pool, remote_repositories, installed_repository)
    transaction = solver.solve(request)
    print(transaction)
Example #2
0
def print_rules(request, remote_repositories, installed_repository):
    pool = Pool(remote_repositories)
    pool.add_repository(installed_repository)

    solver = Solver(pool, remote_repositories, installed_repository)
    rules, _ = solver._create_rules_and_policy(request)
    for rule in rules:
        print(rule.to_string(pool))
    def _check_solution(self, filename):
        # Test that the solution described in the scenario file matches with
        # what the SAT solver computes.

        # Given
        scenario = Scenario.from_yaml(os.path.join(os.path.dirname(__file__), 
                                      filename))
        pool = Pool(scenario.remote_repositories)
        requirement = _get_requirement_from_request_block(scenario.request)
        rules = generate_rules_for_requirement(pool, requirement)

        # When
        solution = optimize(pool, requirement, rules)

        # Then
        decisions = set(pool.package_id(p) for p in solution)
        self.assertItemsEqual(decisions, scenario.decisions.keys())
    def _check_solution(self, filename):
        # Test that the solution described in the scenario file matches with
        # what the SAT solver computes.

        # Given
        scenario = Scenario.from_yaml(os.path.join(os.path.dirname(__file__), 
                                      filename))
        request = scenario.request

        # When
        pool = Pool(scenario.remote_repositories)
        pool.add_repository(scenario.installed_repository)
        solver = Solver(pool, scenario.remote_repositories,
                        scenario.installed_repository)
        transaction = solver.solve(request)

        # Then
        self.assertEqualOperations(transaction.operations,
                                   scenario.operations)