Example #1
0
    def test_multi_coverage_simple(self):
        """Simple test, paris and lima are in the same region, should be easy"""
        self._mock_function(['france'], ['france'])

        region = compute_regions(self.args)

        assert region == self.regions['france'].name
Example #2
0
    def test_multi_coverage_overlap(self):
        """orig as 2 possible region and dest one"""
        self._mock_function(['france', 'peru'], ['peru'])

        region = compute_regions(self.args)

        assert region == self.regions['peru'].name
Example #3
0
    def test_multi_coverage_overlap_chose_non_free(self):
        """orig as 2 possible region and destination 3, we want to chose the france because equador is free"""
        self._mock_function(['france', 'equador'],
                            ['france', 'peru', 'equador'])

        region = compute_regions(self.args)

        assert region == self.regions['france'].name
Example #4
0
    def test_multi_coverage_overlap_chose_non_free2(self):
        """all regions and overlaping, we have to return one of the non free region (we don't know which one)"""
        self._mock_function(['france', 'equador', 'peru', 'bolivia'],
                            ['france', 'equador', 'peru', 'bolivia'])

        region = compute_regions(self.args)

        assert region in [
            self.regions['france'].name, self.regions['peru'].name
        ]
Example #5
0
    def test_multi_coverage_overlap_chose_non_free(self):
        """orig as 2 possible region and destination 3, we want to have france first because equador is free"""
        self._mock_function(['france', 'equador'],
                            ['france', 'peru', 'equador'])

        regions = compute_regions(self.args)

        assert len(regions) == 2
        print("regions ==> {}".format(regions))

        assert regions[0].name == self.regions['france'].name
        assert regions[1].name == self.regions['equador'].name
Example #6
0
    def test_multi_coverage_overlap_chose_with_non_free_and_priority(self):
        """
        all regions are overlaping,
        regions are sorted by priority desc
        """
        self._mock_function(['france', 'netherlands', 'germany'],
                            ['france', 'netherlands', 'germany'])

        regions = compute_regions(self.args)

        assert len(regions) == 3
        print("regions ==> {}".format(regions))

        assert regions[0].name == self.regions['germany'].name
        assert regions[1].name == self.regions['netherlands'].name
        assert regions[2].name == self.regions['france'].name
Example #7
0
    def test_multi_coverage_overlap_chose_non_free2_with_priority_zero(self):
        """
        all regions are overlaping,
        we have to have the non free first then the free (but we don't know which one)
        """
        self._mock_function(['france', 'equador', 'peru', 'bolivia'],
                            ['france', 'equador', 'peru', 'bolivia'])

        regions = compute_regions(self.args)

        assert len(regions) == 4
        print("regions ==> {}".format(regions))

        assert set([regions[0].name, regions[1].name]) == set(
            [self.regions['france'].name, self.regions['peru'].name])
        assert set([regions[2].name, regions[3].name]) == set(
            [self.regions['equador'].name, self.regions['bolivia'].name])
Example #8
0
    def test_multi_coverage_diff_multiple_region(self):
        """orig and dest are in different multiple regions"""
        self._mock_function(['france', 'bolivia'], ['peru', 'equador'])

        compute_regions(self.args)
Example #9
0
    def test_multi_coverage_no_region(self):
        """no orig not dest"""
        self._mock_function(None, None)

        compute_regions(self.args)
Example #10
0
    def test_multi_coverage_no_region(self):
        """no orig """
        self._mock_function(None, ['peru'])

        compute_regions(self.args)
Example #11
0
    def test_multi_coverage_diff_region(self):
        """orig and dest are in different region"""
        self._mock_function(['france'], ['peru'])

        compute_regions(self.args)