def test_calculate_depends_for_topological_order(self):
        def create_mock(name, rundeps):
            m = Mock()
            m.name = name
            m.builddeps = []
            m.buildtooldeps = []
            m.rundeps = rundeps
            m.exports = []
            return m

        mockproject1 = _ProjectDecorator(create_mock('n1', []), 'p1')
        mockproject2 = _ProjectDecorator(create_mock('n2', []), 'p2')
        mockproject3 = _ProjectDecorator(create_mock('n3', []), 'p3')
        mockproject4 = _ProjectDecorator(create_mock('n4', []), 'p4')
        mockproject5 = _ProjectDecorator(create_mock('n5', [mockproject4]), 'p5')
        mockproject6 = _ProjectDecorator(create_mock('n6', [mockproject5]), 'p6')
        mockproject7 = _ProjectDecorator(create_mock('n7', []), 'p7')

        mockproject = Mock()
        mockproject.builddeps = [mockproject1, mockproject2]
        mockproject.buildtooldeps = [mockproject3, mockproject6]
        mockproject.rundeps = [mockproject7]
        mockproject.exports = []

        pd = _ProjectDecorator(mockproject, 'foo/bar')
        # 2 and 3 as external dependencies
        projects = {mockproject1.name: mockproject1,
                    mockproject4.name: mockproject4,
                    mockproject5.name: mockproject5,
                    mockproject6.name: mockproject6}

        pd.calculate_depends_for_topological_order(projects)
        self.assertEqual(set([mockproject1.name, mockproject4.name, mockproject5.name, mockproject6.name]), pd.depends_for_topological_order)
 def create_mock(name, rundeps):
     m = Mock()
     m.name = name
     m.builddeps = []
     m.buildtooldeps = []
     m.rundeps = rundeps
     m.exports = []
     return m
 def create_mock(name, builddeps, path):
     m = Mock()
     m.name = name
     m.builddeps = builddeps
     m.buildtooldeps = []
     m.rundeps = []
     m.exports = []
     m.path = path
     return m