Пример #1
0
def test__verify_entry__url_name(user, substitutions_apps):
    """Tests verify entry page URL name."""
    # Give user required permissions
    utils.add_view_permission(user)

    # Create client and force user login
    client = Client()
    client.force_login(user)

    # Test POST request

    # Test POST request
    post_data = {
        'app_id': substitutions_apps.pk,
        'pend_id': 1,
        'orig': {
            'orig': 'test'
        },
        'subs': {
            'subs': 'test'
        },
    }
    response = client.post(reverse('sub_verify_entry'), post_data)

    assert response.status_code == 201
Пример #2
0
def test__review__context(user):
    """Confirms review view returns expected context details.

        Need to load permissions properly here to get full response
        context.
    """
    # Create apps instance for testing
    apps = models.Apps.objects.create(
        app_name='hc_dpd',
        model_pending='SubBrandPend',
        model_sub='SubBrand',
    )

    # Add user permissions
    utils.add_view_permission(user)

    # Create client and force user login
    client = Client()
    client.force_login(user)

    # Get response
    response = client.get(reverse('sub_review', kwargs={'app_id': apps.pk}))

    # Test for context key
    assert 'app_data' in response.context

    # Confirm proper data
    assert response.context['app_data'] == {
        'id': apps.pk,
        'app_name': apps.app_name,
        'pending': apps.model_pending,
        'sub': apps.model_sub,
    }
Пример #3
0
def test__verify_entry__exists_at_desired_url(user, substitutions_apps):
    """Tests verify entry page exists at desired URL."""
    # Give user required permissions
    utils.add_view_permission(user)

    # Create client and force user login
    client = Client()
    client.force_login(user)

    # Test POST request
    post_data = {
        'app_id': substitutions_apps.pk,
        'pend_id': 1,
        'orig': {
            'orig': 'test'
        },
        'subs': {
            'subs': 'test'
        },
    }
    response = client.post(
        '/tools/substitutions/review/verify-entry/',
        post_data,
    )

    assert response.status_code == 201
Пример #4
0
def test__dashboard__url_name(user):
    """Tests that dashboard page URL name works."""
    # Give user required permissions
    utils.add_view_permission(user)

    # Create client and force user login
    client = Client()
    client.force_login(user)

    # Test GET request
    response = client.get(reverse('sub_dashboard'))

    assert response.status_code == 200
Пример #5
0
def test__dashboard__exists_at_desired_url(user):
    """Tests that dashboard page exists at desired URL."""
    # Give user required permissions
    utils.add_view_permission(user)

    # Create client and force user login
    client = Client()
    client.force_login(user)

    # Test GET request
    response = client.get('/tools/substitutions/')

    assert response.status_code == 200
Пример #6
0
def test__delete_entry__url_name(user):
    """Tests delete entry page URL name."""
    # Give user required permissions
    utils.add_view_permission(user)

    # Create client and force user login
    client = Client()
    client.force_login(user)

    # Test POST request
    post_data = {'app_id': 1, 'pend_id': 1}
    response = client.post(reverse('sub_delete_entry'), post_data)

    assert response.status_code == 204
Пример #7
0
def test__review__url_name(user, substitutions_apps):
    """Tests review page URL name works."""
    # Give user required permissions
    utils.add_view_permission(user)

    # Create client and force user login
    client = Client()
    client.force_login(user)

    # Test GET request
    response = client.get(
        reverse('sub_review', kwargs={'app_id': substitutions_apps.pk}))

    assert response.status_code == 200
Пример #8
0
def test__review__exists_at_desired_url(user, substitutions_apps):
    """Tests review page exists at desired URL."""
    # Give user required permissions
    utils.add_view_permission(user)

    # Create client and force user login
    client = Client()
    client.force_login(user)

    # Test GET request
    response = client.get(
        f'/tools/substitutions/review/{substitutions_apps.pk}/')

    assert response.status_code == 200
Пример #9
0
def test__dashboard__200_response(user, substitutions_apps):  # pylint: disable=unused-argument
    """Confirms dashboard view returns 200 response."""
    # Add user permissions
    utils.add_view_permission(user)

    # Create client and force user login
    client = Client()
    client.force_login(user)

    # Get response
    response = client.get(reverse('sub_dashboard'))

    # Confirm status code
    assert response.status_code == 200
Пример #10
0
def test__delete_entry__exists_at_desired_url(user):
    """Tests delete entry page exists at desired URL."""
    # Give user required permissions
    utils.add_view_permission(user)

    # Create client and force user login
    client = Client()
    client.force_login(user)

    # Test POST request
    post_data = {'app_id': 1, 'pend_id': 1}
    response = client.post('/tools/substitutions/review/delete-entry/',
                           post_data)

    assert response.status_code == 204
Пример #11
0
def test__review__template(user):
    """Confirms review view returns expected template."""
    # Create apps instance for testing
    apps = models.Apps.objects.create(
        app_name='hc_dpd',
        model_pending='SubBrandPend',
        model_sub='SubBrand',
    )

    # Add user permissions
    utils.add_view_permission(user)

    # Create client and force user login
    client = Client()
    client.force_login(user)

    # Get response
    response = client.get(reverse('sub_review', kwargs={'app_id': apps.pk}))

    # Test for template
    assert 'substitutions/review.html' in [t.name for t in response.templates]
Пример #12
0
def test__review__200_response(user):
    """Confirms review view returns 200 response."""
    # Create apps instance for testing
    apps = models.Apps.objects.create(
        app_name='hc_dpd',
        model_pending='SubBrandPend',
        model_sub='SubBrand',
    )

    # Add user permissions
    utils.add_view_permission(user)

    # Create client and force user login
    client = Client()
    client.force_login(user)

    # Get response
    response = client.get(reverse('sub_review', kwargs={'app_id': apps.pk}))

    # Confirm status code
    assert response.status_code == 200
Пример #13
0
def test__dashboard__context(user):
    """Confirms dashboard view returns expected context details.

        Need to load permissions properly here to get full response
        context.
    """
    # Create apps instance for testing
    apps = models.Apps.objects.create(
        app_name='hc_dpd',
        model_pending='SubBrandPend',
        model_sub='SubBrand',
    )

    # Add user permissions
    utils.add_view_permission(user)

    # Create client and force user login
    client = Client()
    client.force_login(user)

    # Get response
    response = client.get(reverse('sub_dashboard'))

    # Test for context key
    assert 'sub_data' in response.context

    # Confirm proper data
    assert response.context['sub_data'] == {
        'hc_dpd': {
            'app_name':
            'Health Canada Drug Product Database',
            'data': [{
                'count': 0,
                'id': apps.id,
                'pending': 'Substitution - Brand Name (Pending)',
                'sub': 'SubBrand',
            }],
        }
    }
Пример #14
0
def test__dashboard__template(user, substitutions_apps):  # pylint: disable=unused-argument
    """Confirms dashboard view returns expected template."""
    # Create apps instance for testing
    models.Apps.objects.create(
        app_name='hc_dpd',
        model_pending='SubBrandPend',
        model_sub='SubBrand',
    )

    # Add user permissions
    utils.add_view_permission(user)

    # Create client and force user login
    client = Client()
    client.force_login(user)

    # Get response
    response = client.get(reverse('sub_dashboard'))

    # Test for template
    assert 'substitutions/dashboard.html' in [
        t.name for t in response.templates
    ]