Skip to content

Instantly share code, notes, and snippets.

View AndyLPK247's full-sized avatar

Pandy Knight AndyLPK247

View GitHub Profile
@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_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 / 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 / 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 / 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_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 / test_calc_func.py
Created March 14, 2017 03:08
Python Testing 101 pytest Example: Math Function Tests (2)
def test_divide_by_zero():
with pytest.raises(ZeroDivisionError) as e:
divide(NUMBER_1, 0)
assert "division by zero" in str(e.value)
@AndyLPK247
AndyLPK247 / test_calc_func.py
Created March 14, 2017 03:05
Python Testing 101 pytest Example: Math Function Tests (1)
import pytest
from com.automationpanda.example.calc_func import *
NUMBER_1 = 3.0
NUMBER_2 = 2.0
def test_add():
value = add(NUMBER_1, NUMBER_2)
assert value == 5.0
@AndyLPK247
AndyLPK247 / calc_func.py
Created March 14, 2017 02:58
Python Testing 101 pytest Example: Math Functions
def add(a, b):
return a + b
def subtract(a, b):
return a - b
def multiply(a, b):
return a * b
@AndyLPK247
AndyLPK247 / pytest.ini
Created March 14, 2017 02:55
Python Testing 101 pytest Example: Config File
# Add pytest options here
[pytest]