Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@pytest.mark.integration
def test_controller_create(test_dao, test_configuration):
""" __init__() should return a Failure Definition Data Controller. """
DUT = dtcFailureDefinition(test_dao, test_configuration, test=True)
assert isinstance(DUT, dtcFailureDefinition)
assert isinstance(DUT._dtm_data_model, dtmFailureDefinition)
@pytest.mark.integration
def test_imperative_config_method_with_dotted_path():
config = _make_config()
config.add_simple_route(
'/path/to/view',
'tests.simple_app.MyViewsClass',
attr='imperative_view',
renderer='json'
)
response = _make_app(config).get('/path/to/view', status=200)
assert response.content_type == 'application/json'
assert response.json == {'foo': 'bar'}
@pytest.mark.integration
def test_set_attributes_too_few_passed(test_dao):
""" set_attributes() should return a zero error code when passed too few attributes. """
_session = test_dao.RAMSTK_SESSION(
bind=test_dao.engine, autoflush=False, expire_on_commit=False)
DUT = _session.query(RAMSTKMission).first()
ATTRIBUTES.pop('time_units')
_error_code, _msg = DUT.set_attributes(ATTRIBUTES)
assert _error_code == 40
assert _msg == ("RAMSTK ERROR: Missing attribute 'time_units' in attribute "
"dictionary passed to RAMSTKMission.set_attributes().")
@pytest.mark.integration
@pytest.mark.vcr(filter_headers=["authorization"])
def test_refund(payment_txn_captured, sandbox_braintree_gateway_config):
amount = Decimal("10.00")
TRANSACTION_ID = "rjfqmf3r"
payment_info = create_payment_information(
payment_txn_captured, TRANSACTION_ID, amount
)
response = refund(payment_info, sandbox_braintree_gateway_config)
assert not response.error
assert response.kind == TransactionKind.REFUND
assert response.amount == amount
assert response.currency == "EUR"
assert response.is_success is True
@pytest.mark.integration
def test_end_training(coordinator_service):
assert coordinator_service.coordinator.round.updates == {}
# simulate trained local model data
test_weights, number_samples = [np.arange(20, 30), np.arange(30, 40)], 2
metrics = {"metric": [np.arange(10, 20), np.arange(5, 10)]}
with grpc.insecure_channel("localhost:50051") as channel:
# we first need to rendezvous before we can send any other request
rendezvous(channel)
# call endTraining service method on coordinator
end_training( # pylint: disable-msg=no-value-for-parameter
channel, test_weights, number_samples, metrics
)
# check local model received...
@pytest.mark.integration
def test_ramstkfailuredefinition_create(test_dao):
""" __init__() should create an RAMSTKFailureDefinition model. """
_session = test_dao.RAMSTK_SESSION(
bind=test_dao.engine, autoflush=False, expire_on_commit=False)
DUT = _session.query(RAMSTKFailureDefinition).first()
assert isinstance(DUT, RAMSTKFailureDefinition)
# Verify class attributes are properly initialized.
assert DUT.__tablename__ == 'ramstk_failure_definition'
assert DUT.revision_id == 1
assert DUT.definition_id == 1
assert DUT.definition == b'Failure Definition'
@pytest.mark.integration
def test_ref_all_of(engine, sessionmaker, spec):
"""
GIVEN specification with a schema that has a $ref on a column
WHEN schema is created and an instance is added to the session
THEN the instance is returned when the session is queried for it.
"""
# Creating model factory
base = declarative.declarative_base()
model_factory = open_alchemy.init_model_factory(spec=spec, base=base)
model = model_factory(name="Table")
# Creating models
base.metadata.create_all(engine)
# Creating model instance
model_instance = model(column=1)
session = sessionmaker()
@pytest.mark.integration
def test_do_calculate_cause_rpn(test_dao):
""" do_calculate() returns a zero error code on success when calculate the RPN for a cause. """
DUT = dtmFMEA(test_dao, test=True)
DUT.do_select_all(parent_id=1, functional=False)
for _node in DUT.tree.all_nodes():
try:
_attributes = _node.data.get_attributes()
if _node.data.is_mode:
_attributes['rpn_severity'] = 7
_attributes['rpn_severity_new'] = 4
if _node.data.is_mechanism or _node.data.is_cause:
_attributes['rpn_detection'] = 4
_attributes['rpn_occurrence'] = 7
_attributes['rpn_detection_new'] = 3
_attributes['rpn_occurrence_new'] = 5
@pytest.mark.integration
def test_do_insert_non_existent_type(test_dao):
""" do_insert() should return a 2105 error code when attempting to add something other than a Mission, Phase, or Environment. """
DUT = dtmUsageProfile(test_dao, test=True)
DUT.do_select_all(revision_id=1)
_error_code, _msg = DUT.do_insert(
entity_id=1, parent_id=0, level='scadamoosh')
assert _error_code == 2005
assert _msg == ("RAMSTK ERROR: Attempted to add an item to the Usage "
"Profile with an undefined indenture level. Level "
@pytest.mark.integration
def test_do_update(test_dao):
""" do_update() should return a zero error code on success. """
DUT = dtmFMEA(test_dao, test=True)
DUT.do_select_all(parent_id=1, functional=True)
_error_code, _msg = DUT.do_update('0.1')
assert _error_code == 0
assert _msg == ("RAMSTK SUCCESS: Updating the RAMSTK Program database.")