Skip to content

Commit

Permalink
Rename lambda folder to thin_egress_app
Browse files Browse the repository at this point in the history
  • Loading branch information
reweeden committed Mar 3, 2023
1 parent a532520 commit ee6989e
Show file tree
Hide file tree
Showing 13 changed files with 22 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- run: pip install pytest-github-actions-annotate-failures

- run: pytest --cov=lambda --cov-report=term-missing --cov-report=xml --cov-branch tests
- run: pytest --cov=thin_egress_app --cov-report=term-missing --cov-report=xml --cov-branch tests

- name: Report coverage
uses: codecov/codecov-action@v2
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
/terraform/providers.tf
terraform.tfstate*
*.tfvars
/lambda/.chalice
/thin_egress_app/.chalice
.coverage

# Config
Expand Down
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
SOURCES := \
lambda/var/otel-config/collector.yaml \
lambda/app.py \
lambda/tea_bumper.py \
lambda/update_lambda.py
thin_egress_app/var/otel-config/collector.yaml \
thin_egress_app/app.py \
thin_egress_app/tea_bumper.py \
thin_egress_app/update_lambda.py

HTML_TEMPLATES := $(wildcard templates/*.html)
MD_TEMPLATES := $(wildcard templates/*.md)
Expand All @@ -15,7 +15,7 @@ REQUIREMENTS_TXT := $(REQUIREMENTS_IN:.in=.txt)
DIR := dist
EMPTY := $(DIR)/empty
# Temporary artifacts
DIST_SOURCES := $(SOURCES:lambda/%=$(DIR)/code/%)
DIST_SOURCES := $(SOURCES:thin_egress_app/%=$(DIR)/code/%)
DIST_MD_RESOURCES := $(MD_TEMPLATES:%.md=$(DIR)/code/%.html)
DIST_HTML_RESOURCES := $(HTML_TEMPLATES:%=$(DIR)/code/%)
DIST_RESOURCES := $(DIST_HTML_RESOURCES) $(DIST_MD_RESOURCES)
Expand Down Expand Up @@ -119,7 +119,7 @@ $(DIST_HTML_RESOURCES): $(DIR)/code/%: %
cp $< $@

.SECONDARY: $(DIST_SOURCES)
$(DIST_SOURCES): $(DIR)/code/%: lambda/%
$(DIST_SOURCES): $(DIR)/code/%: thin_egress_app/%
@mkdir -p $(@D)
cp $< $@
$(PYTHON) scripts/sed.py -i $@ "<BUILD_ID>" "${BUILD_ID}"
Expand Down Expand Up @@ -286,4 +286,4 @@ lock: $(REQUIREMENTS_TXT)

.PHONY: test
test:
pytest --cov=lambda --cov-report=term-missing --cov-branch tests
pytest --cov=thin_egress_app --cov-report=term-missing --cov-branch tests
2 changes: 1 addition & 1 deletion docs/technical.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ file, parses out the IP CIDRs for the deploy region, and automatically
updates the In-Region IAM Role's Policy Document `condition` block.

This lambda is defined in
[update_lambda.py](https://github.com/asfadmin/thin-egress-app/blob/master/lambda/update_lambda.py)
[update_lambda.py](https://github.com/asfadmin/thin-egress-app/blob/master/thin_egress_app/update_lambda.py)

## Build Process

Expand Down
5 changes: 2 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@
mock_boto3 = mock.create_autospec(real_boto3)
sys.modules["boto3"] = mock_boto3

# Can't import normally because 'lambda' is a reserved word
# Need to import these modules first because they will override the log level at import time
_ = importlib.import_module("lambda.app")
_ = importlib.import_module("lambda.tea_bumper")
import thin_egress_app.app # noqa: E402
import thin_egress_app.tea_bumper # noqa: E401,E402

root_logger = logging.getLogger()
for handler in root_logger.handlers:
Expand Down
9 changes: 4 additions & 5 deletions tests/test_app.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import base64
import contextlib
import importlib
import io
from unittest import mock
from urllib.error import HTTPError
Expand All @@ -12,9 +11,9 @@
from chalice.test import Client
from rain_api_core.auth import UserProfile

MODULE = "lambda.app"
# Can't import normally because 'lambda' is a reserved word
app = importlib.import_module(MODULE)
from thin_egress_app import app

MODULE = "thin_egress_app.app"


@pytest.fixture
Expand Down Expand Up @@ -476,7 +475,7 @@ def test_make_redirect(current_request):

def test_make_html_response(monkeypatch):
mock_render = mock.Mock(return_value="<html></html>")
monkeypatch.setattr("lambda.app.TEMPLATE_MANAGER.render", mock_render)
monkeypatch.setattr(f"{MODULE}.TEMPLATE_MANAGER.render", mock_render)

response = app.make_html_response({"foo": "bar"}, {"baz": "qux"})
assert response.body == "<html></html>"
Expand Down
6 changes: 3 additions & 3 deletions tests/test_tea_bumper.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import importlib
from unittest import mock

import pytest

MODULE = "lambda.tea_bumper"
tea_bumper = importlib.import_module(MODULE)
from thin_egress_app import tea_bumper

MODULE = "thin_egress_app.tea_bumper"


@pytest.fixture
Expand Down
6 changes: 3 additions & 3 deletions tests/test_update_lambda.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import importlib
import io
import json
from unittest import mock

import pytest

MODULE = "lambda.update_lambda"
update_lambda = importlib.import_module(MODULE)
from thin_egress_app import update_lambda

MODULE = "thin_egress_app.update_lambda"


@pytest.fixture
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit ee6989e

Please sign in to comment.