コード例 #1
0
class FileRepoTestCase(unittest.TestCase):
    @mock.patch('debile.utils.deb822.Changes', return_value='Update package')
    def setUp(self, mock):
        self.filerepo = FileRepo()
        self.dud = Dud(string='Update package')

    @mock.patch('os.path.isdir', return_value=True)
    def test_add_dud_but_files_already_exist(self, mock):
        self.assertRaises(FilesAlreadyRegistered, self.filerepo.add_dud,
                          '/tmp/', self.dud, 666)

    @mock.patch('os.path.isdir', return_value=False)
    @mock.patch('os.makedirs')
    @mock.patch('debile.master.dud.Dud.get_dud_file',
                return_value=['debile.dud'])
    @mock.patch('debile.master.dud.Dud.get_files', return_value=['debile'])
    @mock.patch('shutil.copy2')
    @mock.patch('os.chmod')
    @mock.patch('os.path.basename', return_value='debile')
    def test_add_dud(self, mock_basename, mock_chmod, mock_copy,
                     mock_get_files, mock_dud, mock_makedirs, mock_path):
        self.filerepo.add_dud('/tmp', self.dud, 666)

        self.assertTrue(mock_makedirs.called)
        self.assertTrue(mock_copy.called)

        args, _ = mock_copy.call_args

        self.assertEquals(args, ('debile', '/tmp'))
        self.assertTrue(mock_chmod.called)

        args, kwargs = mock_chmod.call_args

        self.assertEquals(args, ('/tmp/debile', 666))
コード例 #2
0
ファイル: incoming_dud.py プロジェクト: opencollab/debile
def accept_dud(config, session, dud, builder):
    fire = dud.get_firehose()
    failed = True if dud.get('X-Debile-Failed', None) == "Yes" else False

    job = session.query(Job).get(dud['X-Debile-Job'])

    fire, _ = idify(fire)
    fire = uniquify(session.bind, fire)

    result = job.new_result(fire, failed)
    session.add(result)

    try:
        repo = FileRepo()
        repo.add_dud(result.path, dud, config['filerepo_chmod_mode'])
    except FilesAlreadyRegistered:
        return reject_dud(session, dud, "dud-files-already-registered")

    emit('receive', 'result', result.debilize())

    # OK. It's safely in the database and repo. Let's cleanup.
    for fp in [dud.get_dud_file()] + dud.get_files():
        os.unlink(fp)
コード例 #3
0
ファイル: incoming_dud.py プロジェクト: Debian/debile
def accept_dud(config, session, dud, builder):
    fire = dud.get_firehose()
    failed = True if dud.get('X-Debile-Failed', None) == "Yes" else False

    job = session.query(Job).get(dud['X-Debile-Job'])

    fire, _ = idify(fire)
    fire = uniquify(session.bind, fire)

    result = job.new_result(fire, failed)
    session.add(result)

    try:
        repo = FileRepo()
        repo.add_dud(result.path, dud, config['filerepo_chmod_mode'])
    except FilesAlreadyRegistered:
        return reject_dud(session, dud, "dud-files-already-registered")

    emit('receive', 'result', result.debilize())

    # OK. It's safely in the database and repo. Let's cleanup.
    for fp in [dud.get_dud_file()] + dud.get_files():
        os.unlink(fp)
コード例 #4
0
ファイル: test_filerepo.py プロジェクト: johngian/debile
class FileRepoTestCase(unittest.TestCase):
    @mock.patch('debile.utils.deb822.Changes', return_value='Update package')
    def setUp(self, mock):
        self.filerepo = FileRepo()
        self.dud = Dud(string='Update package')


    @mock.patch('os.path.isdir', return_value=True)
    def test_add_dud_but_files_already_exist(self, mock):
        self.assertRaises(FilesAlreadyRegistered, self.filerepo.add_dud,
                '/tmp/', self.dud, 666)


    @mock.patch('os.path.isdir', return_value=False)
    @mock.patch('os.makedirs')
    @mock.patch('debile.master.dud.Dud.get_dud_file',
            return_value=['debile.dud'])
    @mock.patch('debile.master.dud.Dud.get_files', return_value=['debile'])
    @mock.patch('shutil.copy2')
    @mock.patch('os.chmod')
    @mock.patch('os.path.basename', return_value='debile')
    def test_add_dud(self, mock_basename, mock_chmod, mock_copy, mock_get_files,
            mock_dud, mock_makedirs, mock_path):
        self.filerepo.add_dud('/tmp', self.dud, 666)

        self.assertTrue(mock_makedirs.called)
        self.assertTrue(mock_copy.called)

        args,_ = mock_copy.call_args

        self.assertEquals(args, ('debile', '/tmp'))
        self.assertTrue(mock_chmod.called)

        args,kwargs = mock_chmod.call_args

        self.assertEquals(args, ('/tmp/debile', 666))
コード例 #5
0
ファイル: test_filerepo.py プロジェクト: johngian/debile
 def setUp(self, mock):
     self.filerepo = FileRepo()
     self.dud = Dud(string='Update package')
コード例 #6
0
 def setUp(self, mock):
     self.filerepo = FileRepo()
     self.dud = Dud(string='Update package')