# Path: tenable_io/api/scans.py
# class ScanExportRequest(BaseRequest):
# 
#     CHAPTER_COMPLIANCE = u'compliance'
#     CHAPTER_COMPLIANCE_EXEC = u'compliance_exec'
#     CHAPTER_CUSTOM_VULN_BY_HOST = u'vuln_by_host'
#     CHAPTER_CUSTOM_VULN_BY_PLUGIN = u'vuln_by_plugin'
#     CHAPTER_EXECUTIVE_SUMMARY = u'vuln_hosts_summary'
#     CHAPTER_REMEDIATIONS = u'remediations'
# 
#     FORMAT_CSV = u'csv'
#     FORMAT_DB = u'db'
#     FORMAT_HTML = u'html'
#     FORMAT_NESSUS = u'nessus'
#     FORMAT_PDF = u'pdf'
# 
#     WAS_EXPORT_TYPE = u'web-app'
# 
#     def __init__(
#             self,
#             format,
#             password=None,
#             chapters=None,
#     ):
#         assert format in [
#             ScanExportRequest.FORMAT_CSV,
#             ScanExportRequest.FORMAT_DB,
#             ScanExportRequest.FORMAT_HTML,
#             ScanExportRequest.FORMAT_NESSUS,
#             ScanExportRequest.FORMAT_PDF,
#         ]
#         assert chapters in [
#             None,
#             ScanExportRequest.CHAPTER_COMPLIANCE,
#             ScanExportRequest.CHAPTER_COMPLIANCE_EXEC,
#             ScanExportRequest.CHAPTER_CUSTOM_VULN_BY_HOST,
#             ScanExportRequest.CHAPTER_CUSTOM_VULN_BY_PLUGIN,
#             ScanExportRequest.CHAPTER_EXECUTIVE_SUMMARY,
#             ScanExportRequest.CHAPTER_REMEDIATIONS,
#         ]
#         self.format = format
#         self.password = password
#         self.chapters = chapters
# 
#     def as_payload(self, filter_=None):
#         return super(ScanExportRequest, self).as_payload(True)
# 
# Path: tests/config.py
# class TenableIOTestConfig(object):
# 
#     @staticmethod
#     def get(key):
#         return config.get('tenable_io-test', key)


import os
import pytest
from time import time
from random import randint
from tenable_io.api.scans import ScanExportRequest
from tests.config import TenableIOTestConfig
    scan = create_scan(client)
    cancel_after_seconds = 10

    start_time = time()
    scan.launch().wait_or_cancel_after(cancel_after_seconds)
    stop_time = time()

    assert stop_time - start_time >= cancel_after_seconds, \
        u'Scan is ran for at least %s seconds.' % cancel_after_seconds
    assert scan.stopped(), u'Scan is stopped.'


@pytest.mark.vcr()
def test_scan_helper_return_last_history(client):
    scan = create_scan(client)
    for _ in range(2):
        scan.launch().wait_or_cancel_after(10)
        assert scan.stopped(), u'Scan is stopped.'
    scan_histories = scan.histories()
    most_recent_history = scan.last_history()
    assert max([h.history_id for h in scan_histories]) == most_recent_history.history_id, \
        u'last_history should return the most recent history.'
    assert max([h.last_modification_date for h in scan_histories]) == most_recent_history.last_modification_date, \
        u'last_history should return the most recent history.'


@pytest.mark.skip()
@pytest.mark.vcr()
def test_scan_helper_activities(client):
    scan = create_scan(client)

# Path: tenable_io/api/scans.py
# class ScanExportRequest(BaseRequest):
# 
#     CHAPTER_COMPLIANCE = u'compliance'
#     CHAPTER_COMPLIANCE_EXEC = u'compliance_exec'
#     CHAPTER_CUSTOM_VULN_BY_HOST = u'vuln_by_host'
#     CHAPTER_CUSTOM_VULN_BY_PLUGIN = u'vuln_by_plugin'
#     CHAPTER_EXECUTIVE_SUMMARY = u'vuln_hosts_summary'
#     CHAPTER_REMEDIATIONS = u'remediations'
# 
#     FORMAT_CSV = u'csv'
#     FORMAT_DB = u'db'
#     FORMAT_HTML = u'html'
#     FORMAT_NESSUS = u'nessus'
#     FORMAT_PDF = u'pdf'
# 
#     WAS_EXPORT_TYPE = u'web-app'
# 
#     def __init__(
#             self,
#             format,
#             password=None,
#             chapters=None,
#     ):
#         assert format in [
#             ScanExportRequest.FORMAT_CSV,
#             ScanExportRequest.FORMAT_DB,
#             ScanExportRequest.FORMAT_HTML,
#             ScanExportRequest.FORMAT_NESSUS,
#             ScanExportRequest.FORMAT_PDF,
#         ]
#         assert chapters in [
#             None,
#             ScanExportRequest.CHAPTER_COMPLIANCE,
#             ScanExportRequest.CHAPTER_COMPLIANCE_EXEC,
#             ScanExportRequest.CHAPTER_CUSTOM_VULN_BY_HOST,
#             ScanExportRequest.CHAPTER_CUSTOM_VULN_BY_PLUGIN,
#             ScanExportRequest.CHAPTER_EXECUTIVE_SUMMARY,
#             ScanExportRequest.CHAPTER_REMEDIATIONS,
#         ]
#         self.format = format
#         self.password = password
#         self.chapters = chapters
# 
#     def as_payload(self, filter_=None):
#         return super(ScanExportRequest, self).as_payload(True)
# 
# Path: tests/config.py
# class TenableIOTestConfig(object):
# 
#     @staticmethod
#     def get(key):
#         return config.get('tenable_io-test', key)


# Path: tests/integration/helpers/test_scan.py
import os
import pytest
from time import time
from random import randint
from tenable_io.api.scans import ScanExportRequest
from tests.config import TenableIOTestConfig

    scan = create_scan(client)
    cancel_after_seconds = 10

    start_time = time()
    scan.launch().wait_or_cancel_after(cancel_after_seconds)
    stop_time = time()

    assert stop_time - start_time >= cancel_after_seconds, \
        u'Scan is ran for at least %s seconds.' % cancel_after_seconds
    assert scan.stopped(), u'Scan is stopped.'


@pytest.mark.vcr()
def test_scan_helper_return_last_history(client):
    scan = create_scan(client)
    for _ in range(2):
        scan.launch().wait_or_cancel_after(10)
        assert scan.stopped(), u'Scan is stopped.'
    scan_histories = scan.histories()
    most_recent_history = scan.last_history()
    assert max([h.history_id for h in scan_histories]) == most_recent_history.history_id, \
        u'last_history should return the most recent history.'
    assert max([h.last_modification_date for h in scan_histories]) == most_recent_history.last_modification_date, \
        u'last_history should return the most recent history.'


@pytest.mark.skip()
@pytest.mark.vcr()
def test_scan_helper_activities(client):
    scan = create_scan(client)

    scan_targets = TenableIOTestConfig.get('scan_text_targets')