Heray-Was-Here
Server : Apache
System : Linux dal-shared-66.hostwindsdns.com 4.18.0-513.24.1.lve.1.el8.x86_64 #1 SMP Thu May 9 15:10:09 UTC 2024 x86_64
User : krnuyqrm ( 1183)
PHP Version : 7.4.33
Disable Function : NONE
Directory :  /lib/python2.7/site-packages/test/unit/sanity/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python2.7/site-packages/test/unit/sanity/test_sanity.py
import pytest

from hw_cpbackup.s3_util import InteractS3
from test.mock.common import S3Session, S3_MOCKDATA
from test.mock.mock_sanity import MockBackupSanity


@pytest.fixture(scope='module')
def bs():
    _bs = MockBackupSanity()
    return _bs


@pytest.fixture()
def s3_session():
    _s3_session = S3Session
    return _s3_session


@pytest.mark.backup_sanity
def test_sanity_bucket_alert(bs, s3_session, mocker):
    """Test whether alerts are properly invoked"""
    bs.s3_session = InteractS3(s3_data=S3_MOCKDATA)
    bs.s3_session._s3_session = s3_session(exists=False)
    bs.run()
    assert not bs.s3_session.bucket_exists
    assert bs.alerted
    bs.reset()
    bs.s3_session._s3_session = s3_session(exists=True, exclude='all')
    bs.run()
    assert not bs.s3_session.backup_keys
    assert bs.alerted
    bs.reset()
    bs.s3_session._s3_session = s3_session(key_size=0)
    bs.run()
    assert bs.s3_session.backup_today
    assert bs.s3_session.backup_zero
    assert bs.alerted
    bs.reset()
    bs.s3_session._s3_session = s3_session(start_date=4)
    bs.run()
    assert bs.s3_session.exceeded_timestamp
    assert bs.alerted
    bs.reset()
    bs.s3_session._s3_session = s3_session(start_date=2)
    bs.run()
    assert not bs.s3_session.backup_today
    assert bs.alerted
    bs.reset()

Hry