예제 #1
0
    def test_import_services(self):
        self.mock(gitiles_import, 'import_config_set', mock.Mock())
        self.mock(gitiles, 'get_tree', mock.Mock())
        gitiles.get_tree.return_value = gitiles.Tree(
            id='abc',
            entries=[
                gitiles.TreeEntry(
                    id='deadbeef',
                    name='luci-config',
                    type='tree',
                    mode=0,
                ),
                gitiles.TreeEntry(
                    id='deadbeef1',
                    name='malformed service id',
                    type='tree',
                    mode=0,
                ),
                gitiles.TreeEntry(
                    id='deadbeef1',
                    name='a-file',
                    type='blob',
                    mode=0,
                ),
            ],
        )

        gitiles_import.import_services(
            gitiles.Location.parse('https://localhost/config'))

        gitiles.get_tree.assert_called_once_with('localhost', 'config', 'HEAD',
                                                 '/')
        gitiles_import.import_config_set.assert_called_once_with(
            'services/luci-config',
            'https://localhost/config/+/HEAD/luci-config')
예제 #2
0
    def test_import_services(self):
        self.mock(gitiles_import, '_import_config_set', mock.Mock())
        self.mock(gitiles, 'get_tree', mock.Mock())
        gitiles.get_tree.return_value = gitiles.Tree(
            id='abc',
            entries=[
                gitiles.TreeEntry(
                    id='deadbeef',
                    name='luci-config',
                    type='tree',
                    mode=0,
                ),
                gitiles.TreeEntry(
                    id='deadbeef1',
                    name='malformed service id',
                    type='tree',
                    mode=0,
                ),
                gitiles.TreeEntry(
                    id='deadbeef1',
                    name='a-file',
                    type='blob',
                    mode=0,
                ),
            ],
        )

        loc = gitiles.Location.parse('https://localhost/config')
        self.assertEqual(gitiles_import._service_config_sets(loc), [
            'services/luci-config',
        ])