def test_for_no_branches_in_versions(): config = Config() config.set_main_option("script_location", "migrations") script = ScriptDirectory.from_config(config) with not_raises(Exception): script.get_current_head()
def test_updating_filing_with_payment_token(session): """Assert that a payment token can be applied to an existing filing.""" from tests.conftest import not_raises filing = Filing() filing.save() with not_raises(BusinessException): filing.payment_token = 'payment token'
def test_check_reduction_validity(): with not_raises(BadRequestException): check_reduction_validity([0], None) check_reduction_validity([], None) check_reduction_validity([1, 2], "SUM") with pytest.raises(BadRequestException): check_reduction_validity([1, 2], None)
def test_check_zoom_validity(): with not_raises(BadRequestException): check_zoom_validity(FakeImagePyramid(100, 100, 1).pyramid, 0) check_zoom_validity(FakeImagePyramid(100, 100, 20).pyramid, 10) check_zoom_validity(FakeImagePyramid(100, 100, 20).pyramid, None) with pytest.raises(BadRequestException): check_zoom_validity(FakeImagePyramid(100, 100, 1).pyramid, 1) with pytest.raises(BadRequestException): check_zoom_validity(FakeImagePyramid(100, 100, 20).pyramid, 25)
def test_safeguard_output_dimensions(): assert safeguard_output_dimensions(SafeMode.UNSAFE, 100, 10000, 10000) == (10000, 10000) assert safeguard_output_dimensions(SafeMode.SAFE_RESIZE, 100, 10, 99) == (10, 99) assert safeguard_output_dimensions(SafeMode.SAFE_RESIZE, 100, 1000, 2000) == (50, 100) assert safeguard_output_dimensions(SafeMode.SAFE_RESIZE, 100, 2000, 1000) == (100, 50) with pytest.raises(TooLargeOutputProblem): assert safeguard_output_dimensions(SafeMode.SAFE_REJECT, 100, 1000, 2000) with not_raises(TooLargeOutputProblem): assert safeguard_output_dimensions(SafeMode.SAFE_REJECT, 100, 10, 99)
def test_business_identifier(session): """Assert that setting the business identifier must be in a valid format.""" from tests.conftest import not_raises valid_identifier = 'CP1234567' invalid_identifier = '1234567' b = Business() with not_raises(BusinessException): b.identifier = valid_identifier with pytest.raises(BusinessException): b.identifier = invalid_identifier
def test_check_array_size(): with not_raises(BadRequestException): check_array_size([1], [1, 2], True) check_array_size(None, [1, 2], True) with pytest.raises(BadRequestException): check_array_size([1], [2], True) with pytest.raises(BadRequestException): check_array_size(None, [1], False) with pytest.raises(BadRequestException): check_array_size([1], [], True)
def test_check_tileindex_validity(): img = FakeImagePyramid(1000, 2000, 1) with not_raises(BadRequestException): check_tileindex_validity(img.pyramid, 0, 0, TierIndexType.ZOOM) check_tileindex_validity(img.pyramid, 0, 0, TierIndexType.LEVEL) check_tileindex_validity(img.pyramid, 31, 0, TierIndexType.ZOOM) check_tileindex_validity(img.pyramid, 31, 0, TierIndexType.LEVEL) with pytest.raises(BadRequestException): check_tileindex_validity(img.pyramid, 32, 0, TierIndexType.ZOOM) with pytest.raises(BadRequestException): check_tileindex_validity(img.pyramid, -1, 0, TierIndexType.ZOOM)
def test_filing_deletion_lock(session, test_name, deletion_lock): """Assert that a filing can be deleted.""" filing = Filing() filing.deletion_locked = deletion_lock filing.save() if deletion_lock: assert filing.locked with pytest.raises(BusinessException): filing.delete() else: assert not filing.locked with not_raises(BusinessException): filing.delete()
def test_filing_orm_delete_allowed_for_in_progress_filing(session): """Assert that attempting to delete a filing will raise a BusinessException.""" from legal_api.exceptions import BusinessException b = factory_business('CP1234567') filing = Filing() filing.business_id = b.id filing.filing_date = datetime.datetime.utcnow() filing.filing_json = ANNUAL_REPORT filing.save() with not_raises(BusinessException): session.delete(filing) session.commit()