def setUp(self):
        """Initialize the configuration."""

        self.obs = OBS()
        Config('openSUSE:Factory')
        self.checkrepo = CheckRepo(APIURL,
                                   project='openSUSE:Factory',
                                   force_clean=True)
        # Des-memoize some functions
        self.checkrepo.build = self.checkrepo._build
        self.checkrepo.last_build_success = self.checkrepo._last_build_success
    def setUp(self):
        """Initialize the configuration."""

        self.obs = OBS()
        self.checkrepo = CheckRepo(APIURL)
        # Des-memoize some functions
        self.checkrepo.build = self.checkrepo._build
        self.checkrepo.last_build_success = self.checkrepo._last_build_success
    def setUp(self):
        """Initialize the configuration."""

        self.obs = OBS()
        Config('openSUSE:Factory')
        self.checkrepo = CheckRepo(APIURL, project='openSUSE:Factory', force_clean=True)
        # Des-memoize some functions
        self.checkrepo.build = self.checkrepo._build
        self.checkrepo.last_build_success = self.checkrepo._last_build_success
class TestCheckRepoCalls(unittest.TestCase):
    """Tests for various check repo calls."""
    def setUp(self):
        """Initialize the configuration."""

        self.obs = OBS()
        Config('openSUSE:Factory')
        self.checkrepo = CheckRepo(APIURL,
                                   project='openSUSE:Factory',
                                   force_clean=True)
        # Des-memoize some functions
        self.checkrepo.build = self.checkrepo._build
        self.checkrepo.last_build_success = self.checkrepo._last_build_success

    def test_packages_grouping(self):
        """Validate the creation of the groups."""
        grouped = {
            1000: 'openSUSE:Factory:Staging:J',
            1001: 'openSUSE:Factory:Staging:J',
            501: 'openSUSE:Factory:Staging:C',
            502: 'openSUSE:Factory:Staging:C',
            333: 'openSUSE:Factory:Staging:B'
        }
        groups = {
            'openSUSE:Factory:Staging:J': [1000, 1001],
            'openSUSE:Factory:Staging:C': [501, 502],
            'openSUSE:Factory:Staging:B': [333]
        }
        self.assertEqual(self.checkrepo.grouped, grouped)
        self.assertEqual(self.checkrepo.groups, groups)

    def test_pending_request(self):
        """Test CheckRepo.get_request."""
        self.assertEqual(len(self.checkrepo.pending_requests()), 2)

    def test_check_specs(self):
        """Test CheckRepo.check_specs."""
        for request in self.checkrepo.pending_requests():
            request_and_specs = self.checkrepo.check_specs(request=request)
            self.assertEqual(len(request_and_specs), 1)
            self.assertTrue(request_and_specs[0].request_id in (1000, 1001))
        for request_id in (1000, 1001):
            request_and_specs = self.checkrepo.check_specs(
                request_id=request_id)
            self.assertEqual(len(request_and_specs), 1)
            self.assertEqual(request_and_specs[0].request_id, request_id)

    def test_repos_to_check(self):
        """Test CheckRepo.repositories_to_check."""
        for request in self.checkrepo.pending_requests():
            request_and_specs = self.checkrepo.check_specs(request=request)
            for rq_or_spec in request_and_specs:
                print self.checkrepo.repositories_to_check(rq_or_spec)
class TestCheckRepoCalls(unittest.TestCase):
    """Tests for various check repo calls."""

    def setUp(self):
        """Initialize the configuration."""

        self.obs = OBS()
        Config('openSUSE:Factory')
        self.checkrepo = CheckRepo(APIURL, project='openSUSE:Factory', force_clean=True)
        # Des-memoize some functions
        self.checkrepo.build = self.checkrepo._build
        self.checkrepo.last_build_success = self.checkrepo._last_build_success

    def test_packages_grouping(self):
        """Validate the creation of the groups."""
        grouped = {
            1000: 'openSUSE:Factory:Staging:J',
            1001: 'openSUSE:Factory:Staging:J',
            501: 'openSUSE:Factory:Staging:C',
            502: 'openSUSE:Factory:Staging:C',
            333: 'openSUSE:Factory:Staging:B'
        }
        groups = {
            'openSUSE:Factory:Staging:J': [1000, 1001],
            'openSUSE:Factory:Staging:C': [501, 502],
            'openSUSE:Factory:Staging:B': [333]
        }
        self.assertEqual(self.checkrepo.grouped, grouped)
        self.assertEqual(self.checkrepo.groups, groups)

    def test_pending_request(self):
        """Test CheckRepo.get_request."""
        self.assertEqual(len(self.checkrepo.pending_requests()), 2)

    def test_check_specs(self):
        """Test CheckRepo.check_specs."""
        for request in self.checkrepo.pending_requests():
            request_and_specs = self.checkrepo.check_specs(request=request)
            self.assertEqual(len(request_and_specs), 1)
            self.assertTrue(request_and_specs[0].request_id in (1000, 1001))
        for request_id in (1000, 1001):
            request_and_specs = self.checkrepo.check_specs(request_id=request_id)
            self.assertEqual(len(request_and_specs), 1)
            self.assertEqual(request_and_specs[0].request_id, request_id)

    def test_repos_to_check(self):
        """Test CheckRepo.repositories_to_check."""
        for request in self.checkrepo.pending_requests():
            request_and_specs = self.checkrepo.check_specs(request=request)
            for rq_or_spec in request_and_specs:
                print self.checkrepo.repositories_to_check(rq_or_spec)