Exemplo n.º 1
0
def update_scan_state(scan: Scan, state: ScanState, session: Session) -> Scan:
    """Updates a scan state"""
    if scan.id is None:
        raise ValueError('Cant create scans')

    scan.state = state.name
    session.add(scan)
    return scan
Exemplo n.º 2
0
    def test_update_scan_state(self):
        scan_id = '123'
        scan = Scan(id=scan_id, state=scan_manager.ScanState.PENDING)

        scan_manager.update_scan_state(scan, scan_manager.ScanState.INVALID_REPO, self.mock_session)

        scan.state = scan_manager.ScanState.INVALID_REPO.name
        assert self.mock_session.add.called
        self.mock_session.add.assert_called_once_with(scan)
Exemplo n.º 3
0
    def test_update_scan_state(self):
        scan_id = '123'
        scan = Scan(id=scan_id, state=scan_manager.ScanState.PENDING)

        scan_manager.update_scan_state(scan,
                                       scan_manager.ScanState.INVALID_REPO,
                                       self.mock_session)

        scan.state = scan_manager.ScanState.INVALID_REPO.name
        assert self.mock_session.add.called
        self.mock_session.add.assert_called_once_with(scan)