コード例 #1
0
    def test_fetch_dependencies__requirements_exist(
            self, mock_fetch_remote_requirements, mock_fetch_remote_metadata):
        """
        TestShakerMetadata:test_fetch_dependencies__requirements_exist: Get dependencies when requirements file exists
        """
        test_base_dependencies = {
            'test_organisation/test1-formula': {
                'source': '[email protected]:test_organisation/test1-formula.git',
                'constraint': '==v1.0.1',
                'sourced_constraints': [],
                'organisation': 'test_organisation',
                'name': 'test1-formula'
            }
        }
        mock_fetch_remote_requirements.side_effect = [[
            'test_organisation/test2-formula==v2.0.1'
        ], None]

        expected_dependencies = {
            'test_organisation/test1-formula': {
                'sourced_constraints': ['==v1.0.1'],
            },
            'test_organisation/test2-formula': {
                'source': '[email protected]:test_organisation/test2-formula.git',
                'constraint': '==v2.0.1',
                'sourced_constraints': ['==v2.0.1'],
                'organisation': 'test_organisation',
                'name': 'test2-formula'
            }
        }
        mock_fetch_remote_metadata.return_value = None
        tempobj = ShakerMetadata(autoload=False)
        tempobj.dependencies = {}
        tempobj._fetch_dependencies(test_base_dependencies,
                                    ignore_dependency_requirements=False)

        testfixtures.compare(tempobj.dependencies, expected_dependencies)
コード例 #2
0
    def test_fetch_dependencies__already_sourced(
            self, mock_fetch_remote_requirements, mock_fetch_remote_metadata):
        """
        TestShakerMetadata::test_fetch_dependencies_exists: Don't fetch dependencies if we've already sourced them
        """
        test_base_dependencies = {
            'test_organisation/test1-formula': {
                'source': '[email protected]:test_organisation/test1-formula.git',
                'constraint': '==v1.0.1',
                'sourced_constraints': [],
                'organisation': 'test_organisation',
                'name': 'test1-formula'
            }
        }
        mock_fetch_remote_metadata.side_effect = [{
            'formula':
            'test_organisation/test2-formula',
            'dependencies': ["test_organisation/test2-formula==v2.0.1"]
        }, None]

        expected_dependencies = {
            'test_organisation/test1-formula': {
                'sourced_constraints': ['==v1.0.1'],
            },
        }
        mock_fetch_remote_requirements.return_value = None
        tempobj = ShakerMetadata(autoload=False)
        tempobj.dependencies = {
            'test_organisation/test1-formula': {
                'sourced_constraints': ['==v1.0.1']
            }
        }
        tempobj._fetch_dependencies(test_base_dependencies,
                                    ignore_dependency_requirements=False)

        testfixtures.compare(tempobj.dependencies, expected_dependencies)