Beispiel #1
0
    def test_unmatched_repositories_are_kept(self):
        config = StubConfig(watchlist=(('watching', 'foo/.*'), ))

        subscriptions = {
            'foo/foo': {
                'watching': False
            },
            'foo/bar': {
                'watching': False
            },
            'bar/foo': {
                'watching': True
            },
            'bar/bar': {
                'watching': False
            }
        }
        self.assertEquals(
            {
                'watch': ['foo/bar', 'foo/foo'],
                'unwatch': [],
                'keep-watching': ['bar/foo'],
                'keep-not-watching': ['bar/bar']
            },
            UpdateStrategy(config).apply_watchlist(subscriptions))
Beispiel #2
0
    def test_delete_raises_httperrors(self):
        self.mock_github_request('foo', '', method='delete', response_status_code=401)
        self.mocker.replay()

        with self.assertRaises(HTTPError) as cm:
            github.delete('foo', StubConfig())

        self.assertEquals('401 Client Error: Unauthorized', str(cm.exception))
Beispiel #3
0
    def test_put_raises_httperrors(self):
        self.mock_github_request('foo', '["foo"]', method='put', payload='fuhuu',
                                 response_status_code=401)
        self.mocker.replay()

        with self.assertRaises(HTTPError) as cm:
            github.put('foo', StubConfig(), 'fuhuu')

        self.assertEquals('401 Client Error: Unauthorized', str(cm.exception))
    def test_watches_repositories(self):
        data = {
            'watch': ['bar/bar', 'foo/bar'],
            'unwatch': [],
            'keep-watching': [],
            'keep-not-watching': ['foo/foo']
        }
        self.expect_subscription_created('bar/bar')
        self.expect_subscription_created('foo/bar')
        self.mocker.replay()

        updater = SubscriptionsUpdater(StubConfig())
        updater.update(data)
Beispiel #5
0
    def test_get_with_pagination(self):
        page_one = ['foo']
        page_two = ['bar']
        page_three = ['baz']

        self.mock_github_request(
            'foo', json.dumps(page_one), response_headers={
                'link': generate_links('foo', next=2, last=3)})

        self.mock_github_request(
            'foo?page=2', json.dumps(page_two), response_headers={
                'link': generate_links('foo', first=1, prev=1, next=3, last=3)})

        self.mock_github_request(
            'foo?page=3', json.dumps(page_three), response_headers={
                'link': generate_links('foo', first=1, prev=2)})

        self.mocker.replay()
        self.assertEquals(['foo', 'bar', 'baz'], github.get('foo', StubConfig()))
Beispiel #6
0
    def test_strategy_is_top_down(self):
        config = StubConfig(watchlist=(('watching', '.*'), ('not-watching',
                                                            '.*')))

        subscriptions = {
            'foo/foo': {
                'watching': False
            },
            'foo/bar': {
                'watching': False
            },
            'bar/bar': {
                'watching': False
            }
        }
        self.assertEquals(
            {
                'watch': ['bar/bar', 'foo/bar', 'foo/foo'],
                'unwatch': [],
                'keep-watching': [],
                'keep-not-watching': []
            },
            UpdateStrategy(config).apply_watchlist(subscriptions))
Beispiel #7
0
    def test_strategy_with_simple_watchlist_watching_all(self):
        config = StubConfig(watchlist=(('watching', 'foo/bar'),
                                       ('not-watching', 'foo/.*'), ('watching',
                                                                    '.*')))

        subscriptions = {
            'foo/foo': {
                'watching': True
            },
            'foo/bar': {
                'watching': True
            },
            'bar/bar': {
                'watching': True
            }
        }
        self.assertEquals(
            {
                'watch': [],
                'unwatch': ['foo/foo'],
                'keep-watching': ['bar/bar', 'foo/bar'],
                'keep-not-watching': []
            },
            UpdateStrategy(config).apply_watchlist(subscriptions))
Beispiel #8
0
 def test_delete_request(self):
     self.mock_github_request('foo', '', method='delete')
     self.mocker.replay()
     github.delete('foo', StubConfig())
Beispiel #9
0
 def test_put_request(self):
     self.mock_github_request('foo', '["foo"]', method='put', payload='fuhuu')
     self.mocker.replay()
     github.put('foo', StubConfig(), 'fuhuu')