detector package

Subpackages

Submodules

detector.admin module

detector.apps module

class detector.apps.DetectorConfig(app_name, app_module)[source]

Bases: AppConfig

default_auto_field = 'django.db.models.BigAutoField'
name = 'detector'

detector.forms module

detector.models module

detector.test_utilities module

class detector.test_utilities.TestUtilities(methodName='runTest')[source]

Bases: TestCase

A test case class for testing the utilities module.

test_get_score_error()[source]

Test case to verify the behavior of get_score when an error occurs.

test_get_score_label0_gt_label1()[source]

Test case to verify the behavior of get_score when label 0 has a greater score than label 1.

test_get_score_label0_lt_label1()[source]

Test case to verify the behavior of get_score when label 0 has a lower score than label 1.

detector.test_views module

class detector.test_views.DetectorTest(methodName='runTest')[source]

Bases: TestCase

This is a unit test class for testing the views of the “ai_detector” app.

setUp()[source]

This method is a special method in the test case class and is executed before each test method in the class. It sets up a new client instance.

test_ai_detector_get()[source]

This method tests whether the “ai_detector” view function returns a valid HTTP response with a status code of 200, and whether the response contains the expected content and uses the correct template.

test_ai_detector_post()[source]

This method tests whether the “ai_detector” view function can correctly handle a POST request with the given data. It sends a POST request to the “ai_detector” URL with the given data and verifies that the response contains the expected content and the “Back to AI Detector>>>” link.

test_ai_detector_url_is_resolved()[source]

This method tests whether the URL “ai_detector” is resolved correctly and whether it maps to the “ai_detector” view function.

test_handler404()[source]

This method tests whether the custom 404 error page is displayed when an invalid URL is accessed. It sends a GET request to an invalid URL and verifies that the response contains the expected content and uses the correct template.

test_index_get()[source]

This method tests whether the “index” view function returns a valid HTTP response with a status code of 200, and whether the response contains the expected content and uses the correct template.

test_index_url_is_resolved()[source]

This method tests whether the URL “index” is resolved correctly and whether it maps to the “index” view function.

detector.urls module

detector.utilities module

detector.utilities.get_result(data)[source]

This function queries an API to get a result based on the input data. :type name: data object :param data: contains data in form of text provided by the user

detector.utilities.get_score(result)[source]

This function takes a result as input and returns a boolean score based on the label. :type name: result object :param result: contains response object obtained from Huugingface API

detector.views module

detector.views.ai_detector(request)[source]

This function handles requests to the AI detector page. :type name: HttpRequest object :param request: contains metadata about the request

detector.views.index(request)[source]

This function handles requests to the index page. :type name: HttpRequest object :param request: contains metadata about the request

detector.views.page_not_found(response, exception)[source]

This function is called whenever a page is not found (404 error) in the web application. It takes two arguments: - response: The HTTP response object. - exception: The exception that caused the 404 error.

The function renders the ‘404.html’ template and returns the response with the rendered template. This template is typically a custom error page that is displayed to the user when a page is not found.

detector.views.server_error(response)[source]

This function is called whenever there is a server error (500 error) in the web application. It takes one argument: - response: The HTTP response object.

The function renders the ‘500.html’ template and returns the response with the rendered template. This template is typically a custom error page that is displayed to the user when there is a server error.

Module contents