def test_ensure_directory_structure(self):
        with mock.patch('aasemble.django.apps.buildsvc.repodrivers.recursive_render') as recursive_render:
            repo = Repository.objects.get(id=12)
            repodriver = repodrivers.get_repo_driver(repo)
            repodriver.ensure_directory_structure()

            srcdir = os.path.abspath(os.path.join(os.path.dirname(__file__), 'templates', 'buildsvc', 'reprepro'))
            dstdir = '/some/public/dir/eric/eric5'
            context = {'repository': repo}
            recursive_render.assert_called_with(srcdir, dstdir, context)
    def test_export(self):
        repo = mock.MagicMock()
        repodriver = repodrivers.get_repo_driver(repo)
        with mock.patch.multiple(repodriver,
                                 ensure_key=mock.DEFAULT,
                                 ensure_directory_structure=mock.DEFAULT,
                                 export_key=mock.DEFAULT,
                                 _reprepro=mock.DEFAULT) as mocks:
            repodriver.export()

            mocks['ensure_key'].ensure_called_with()
            mocks['ensure_directory_structure'].ensure_called_with()
            mocks['export_key'].ensure_called_with()
            mocks['_reprepro'].ensure_called_with('export')
    def test_process_changes(self, remove_ddebs_from_changes):
        repo = mock.MagicMock()
        repodriver = repodrivers.get_repo_driver(repo)
        with mock.patch.multiple(repodriver,
                                 export=mock.DEFAULT,
                                 ensure_directory_structure=mock.DEFAULT,
                                 _reprepro=mock.DEFAULT) as mocks:

            # Ensure that ensure_directory_structure() is called and ddebs are removed before _reprepro
            mocks['_reprepro'].side_effect = lambda *args: self.assertTrue(mocks['ensure_directory_structure'].called and remove_ddebs_from_changes.called)

            # Ensure that _reprepro() is called before export
            mocks['export'].side_effect = lambda: self.assertTrue(mocks['_reprepro'].called)

            repodriver.process_changes('myseries', '/path/to/changes')

            remove_ddebs_from_changes.assert_called_with('/path/to/changes')
            mocks['export'].assert_called_with()
            mocks['ensure_directory_structure'].ensure_called_with()
            mocks['_reprepro'].ensure_called_with('--ignore=wrongdistribution', 'include', 'myseries', '/path/to/changes')
 def test_basedir(self):
     repo = Repository.objects.get(id=12)
     repodriver = repodrivers.get_repo_driver(repo)
     self.assertEquals(repodriver.basedir, '/some/dir/eric/eric5')
 def test_gpghome(self):
     repo = Repository.objects.get(id=12)
     repodriver = repodrivers.get_repo_driver(repo)
     self.assertEquals(repodriver.gpghome(), '/some/dir/eric/eric5/.gnupg')
 def import_dsc(self, series_name, dsc_file):
     return get_repo_driver(self).import_dsc(series_name, dsc_file)
 def export(self):
     self.first_series()
     return get_repo_driver(self).export()
 def process_changes(self, series_name, changes_file):
     return get_repo_driver(self).process_changes(series_name, changes_file)
 def _key_data(self):
     return get_repo_driver(self).key_data()
 def import_dsc(self, series_name, dsc_file):
     return get_repo_driver(self).import_dsc(series_name, dsc_file)
 def process_changes(self, series_name, changes_file):
     return get_repo_driver(self).process_changes(series_name, changes_file)
 def export(self):
     self.first_series()
     return get_repo_driver(self).export()
 def _key_data(self):
     return get_repo_driver(self).key_data()