Skip to content

Instantly share code, notes, and snippets.

View MGough's full-sized avatar

Merlin Gough MGough

View GitHub Profile
name: Build Tauri App
on:
push:
branches:
- main
jobs:
publish-artifacts:
strategy:
// Based on: https://blog.leog.me/discourse-sso-with-auth0-e49486d0294a
// This must be the last action in the flow, as it potentially redirects the user to discourse and doesn't have a `onContinuePostLogin` hook as we're not expecting Discourse to return them
const DISCOURSE_AUTH0_CLIENT_ID = "<Your client ID>";
const DISCOURSE_DOMAIN = "<Your Discourse Domain>";
// We use this to avoid sending users to Discourse with unverified emails
// As we want Auth0 to handle email verification by default, not Discourse.
// If they're sent to discourse then they'll receive an email from discourse as well as Auth0 asking to independently verify their emails.
const DISCOURSE_NON_VERIFIED_EMAIL_REDIRECT_URL = "<A URL for users with unverified emails>";
a:
00863395735779106D01A3B: 30
00863531904040789C8A4C6: 31
00863604179437128DD9A2B: 32
00873485276243227609735: 33
0087352270643094413B0D7: 34
008736034269259128AC6C7: 35
00883394559972599E77AEC: 36
008B3600524843455E61C85: 37
008C3378065645906E77882: 38
@MGough
MGough / more_reliable_mocks.py
Created November 17, 2019 22:45
Mocking using autospeccing.
from unittest.mock import patch, Mock, create_autospec
from pytest import fixture
from service.example import SomeObjectToTest
from service.imported_class import SomeClassOutOfOurControl
class TestSomeObjectToTest:
@fixture
def expected_result(self):
@MGough
MGough / example_object_someone_else_implemented_v2.py
Created November 17, 2019 22:17
A modified class out of our control
from abc import abstractmethod
class SomeClassOutOfOurControl:
@abstractmethod
def add(self, items):
raise NotImplementedError("We don't care about this")
@MGough
MGough / test_example_object.py
Last active November 17, 2019 22:15
An example of *fragile* unit tests due to bad mocks.
from unittest.mock import patch, Mock
from pytest import fixture
from src.example import SomeObjectToTest
class TestSomeObjectToTest:
@fixture
def expected_result(self):
return 400
@MGough
MGough / example_object_someone_else_implemented.py
Created November 17, 2019 22:04
An abstract class to be used for a unittest.mock example.
from abc import abstractmethod
class SomeClassOutOfOurControl:
@abstractmethod
def add(self, a, b):
raise NotImplementedError("We don't care about this")
@MGough
MGough / example_object_to_test.py
Created November 17, 2019 22:01
An example of an object to test.
from src.imported_class import SomeClassOutOfOurControl
class SomeObjectToTest:
some_property = 5
some_other_property = 10
def __init__(self):
self.calculator = SomeClassOutOfOurControl()
@MGough
MGough / Jenkinsfile
Created June 23, 2019 21:03
Python testing jenkinsfile
// This is just a snippet, not a complete file
try {
stage('Unit Tests') {
// Build our base image
app = docker.build("our-service:PR-${BUILD_ID}")
// Build our test image passing our base image version and our test dockerfile
docker.build("our-service-test:PR-$BUILD_ID", "--build-arg BUILD_VERSION=PR-$BUILD_ID . -f test.Dockerfile")
@MGough
MGough / test.Dockerfile
Last active June 23, 2019 21:07
Docker file to build a testing container
ARG BUILD_VERSION
FROM our-service:$BUILD_VERSION
COPY test /app/test
COPY dev-requirements.txt /app/
RUN pip install -r dev-requirements.txt
CMD python -m pytest --junitxml /app/results.xml --cov=/app/our_codebase --cov-report xml test/