Exemple #1
0
def test_fetch_codes_with_exception(session):  # pylint: disable=unused-argument
    """Assert that code type details can not be fetch by table name."""
    code_type = 'membership_type'
    with patch.object(importlib, 'import_module', side_effect=Exception(Error.UNDEFINED_ERROR, None)):
        with pytest.raises(BusinessException) as exception:
            CodesService.fetch_codes(code_type)

        assert exception.value.code == 'UNDEFINED_ERROR'
Exemple #2
0
def test_fetch_data_model_not_found(session):  # pylint: disable=unused-argument
    """Assert that code type details can be fetch by table name."""
    code_type = 'membership_type1'
    code_result = CodesService.fetch_data_model(code_type)
    assert not code_result

    code_type = 'user'
    code_result = CodesService.fetch_data_model(code_type)
    assert not code_result

    code_type = ''
    code_result = CodesService.fetch_data_model(code_type)
    assert not code_result
Exemple #3
0
def test_fetch_codes_not_found(session):  # pylint: disable=unused-argument
    """Assert that code type details can not be fetch by table name."""
    # Table is not exists
    code_type = 'membership_type1'
    data = CodesService.fetch_codes(code_type)
    assert not data

    data = CodesService.fetch_codes(None)
    assert not data

    data = CodesService.fetch_codes('')
    assert not data

    # The table is not the code, type or status table.
    code_type = 'user'
    data = CodesService.fetch_codes(code_type)
    assert not data
Exemple #4
0
 def get(code_type):
     """Return the codes by giving name."""
     try:
         codes = CodeService.fetch_codes(code_type=code_type)
         if codes is not None:
             response, status = jsonify(codes), http_status.HTTP_200_OK
         else:
             response, status = {'message': f'The code type ({code_type}) could not be found.'}, \
                 http_status.HTTP_404_NOT_FOUND
     except BusinessException as exception:
         response, status = {'code': exception.code, 'message': exception.message}, exception.status_code
     return response, status
Exemple #5
0
def test_fetch_codes(session):  # pylint: disable=unused-argument
    """Assert that code type details can be fetch by table name."""
    code_type = 'membership_type'
    data = CodesService.fetch_codes(code_type)
    assert data is not None
    assert data[0]['name'] == 'USER'
Exemple #6
0
def test_fetch_data_model(session):  # pylint: disable=unused-argument
    """Assert that code type details can be fetch by table name."""
    code_type = 'membership_type'
    c = CodesService.fetch_data_model(code_type)
    assert c is not None