Skip to content

Instantly share code, notes, and snippets.

View AndyLPK247's full-sized avatar

Pandy Knight AndyLPK247

View GitHub Profile
@AndyLPK247
AndyLPK247 / test_calc_func.py
Created March 14, 2017 03:09
Python Testing 101 pytest Examples: Math Function Tests (3)
@pytest.mark.parametrize("a,b,expected", [
(NUMBER_1, NUMBER_2, NUMBER_1),
(NUMBER_2, NUMBER_1, NUMBER_1),
(NUMBER_1, NUMBER_1, NUMBER_1),
])
def test_maximum(a, b, expected):
assert maximum(a, b) == expected
@pytest.mark.parametrize("a,b,expected", [
@AndyLPK247
AndyLPK247 / calc_class.py
Created March 14, 2017 03:11
Python Testing 101 pytest Example: Calculator Class
from com.automationpanda.example.calc_func import *
class Calculator(object):
def __init__(self):
self._last_answer = 0.0
@property
def last_answer(self):
return self._last_answer
@AndyLPK247
AndyLPK247 / test_calc_class.py
Created March 14, 2017 03:21
Python Testing 101 pytest Example: Calculator Class Tests
import pytest
from com.automationpanda.example.calc_class import Calculator
# "Constants"
NUMBER_1 = 3.0
NUMBER_2 = 2.0
# Fixtures
@AndyLPK247
AndyLPK247 / ocst_1_1_1_sensitive_user_data.feature
Created December 8, 2017 04:15
Example Feature File from the OWASP Cloud Security Project (Showing YAML Comments)
# Id: OCST-1.1.1
# Status: Confirmed
# Service: AWS EC2
# Components:
# - User Data
# STRIDE:
# - Elevation of privilege
# - Information disclosure
# References:
# - https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/user-data.html
@AndyLPK247
AndyLPK247 / django_basic_favicon.html
Last active December 15, 2017 03:28
Django HTML template with a basic favicon in the header
<!DOCTYPE html>
<!-- The link tag within the head section adds the favicon to the page. -->
<!-- Presume that the favicon is a static file accessible at the images/favicon path. -->
<!-- Remember to "load static", too! -->
{% load static %}
<html lang="en">
<head>
@AndyLPK247
AndyLPK247 / django_example_parent.html
Created December 15, 2017 04:30
Django parent template example that sets the favicon
<!DOCTYPE html>
<!-- This is a basic example of a Django parent template. -->
<!-- It adds a favicon to the page. -->
<!-- The title is set by overriding the "title" block. -->
<!-- Body content is added by overriding the "content" block. -->
<!-- Tweak this parent template to meet your project's needs. -->
{% load static %}
@AndyLPK247
AndyLPK247 / django_example_child.html
Created December 15, 2017 04:37
Django child template example that inherits the favicon
<!-- This is an example of a Django child template. -->
<!-- It extends: https://gist.github.com/d7f20ccd5620f64d761ec546fd9eb37a -->
<!-- The parent template sets the favicon. -->
{% extends "django_example_parent.html" %}
{% block title %}My Page{% endblock %}
{% block content %}
<div>
@AndyLPK247
AndyLPK247 / django_favicon_admin_base_site.html
Last active December 15, 2017 04:55
Django admin/base_site.html template override for admin site favicon
<!-- The path and name for this file should be "templates/admin/base_site.html". -->
<!-- It overrides the original admin template and will be picked up by all of its children. -->
<!-- This template override has been verified for Django 1.11 and 2.0. -->
{% extends "admin/base_site.html" %}
{% load static %}
{% block extrahead %}
<link rel="shortcut icon" href="{% static 'images/favicon.ico' %}" />
@AndyLPK247
AndyLPK247 / django_favicon_rest_fw_api.html
Created February 9, 2018 19:39
Django rest_framework/api.html template override for Django REST Framework browsable API favicon
<!-- The path and name for this file should be "templates/rest_framework/api.html". -->
<!-- It overrides the original browsable API template and will be picked up by all of its children. -->
<!-- This template override has been verified for Django 2.0. -->
{% extends "rest_framework/base.html" %}
{% load static %}
{% block style %}
{{ block.super }}
@AndyLPK247
AndyLPK247 / django_favicon_settings.py
Created March 11, 2018 21:14
TEMPLATES Example for Django Admin Favicon
TEMPLATES = [
{
# ...
'DIRS': [os.path.join(BASE_DIR, 'templates')],
# ...
},
]