Hacked By AnonymousFox
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()
Hacked By AnonymousFox1.0, Coded By AnonymousFox