Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions Dockerfile_37_111
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
FROM python:3.7-slim-bullseye AS base

ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
DEBIAN_FRONTEND=noninteractive

WORKDIR /code

ARG REQUIREMENTS_FILE=requirements/python3_django111/test.txt

# Install system dependencies (native libs needed to compile Python packages)
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
libffi-dev \
libssl-dev \
libpq-dev \
libjpeg-dev \
zlib1g-dev \
libfreetype6-dev \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*

# Lock pip/setuptools/wheel to last Python 3.7 compatible versions
RUN pip install --no-cache-dir --upgrade \
pip==23.2.1 \
setuptools==68.0.0 \
wheel==0.41.2

# ---------- Application layer ----------
FROM base AS python-fitbit

COPY requirements/ /code/requirements/

RUN pip install --no-cache-dir -r /code/${REQUIREMENTS_FILE}

COPY . /code/

CMD ["make", "test_with_coverage"]
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,10 @@ build_with_django_18:
build_with_django_111:
@echo "Starting Docker build..."
docker build -t python-fitbit111 --build-arg REQUIREMENTS_FILE=requirements/django111/test.txt .
docker run -it --rm python-fitbit111
docker run -it --rm python-fitbit111

# Start build with django version 1.8 and python 3.7
build_with_django_111_37:
@echo "Starting Docker build..."
docker build -f Dockerfile_37_111 -t python-fitbit111-37 --build-arg REQUIREMENTS_FILE=requirements/python3_django111/test.txt .
docker run -it --rm python-fitbit111-37
5 changes: 4 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,7 @@ make build_with_django_18
Build and run docker image with django 1.8

make build_with_django_111
Build and run docker image with django 1.11
Build and run docker image with django 1.11

make build_with_django_111_37
Build and run docker image with django 1.11 and python 3.7
7 changes: 6 additions & 1 deletion fitbit_tests/test_gather_keys_cli.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
import sys
import unittest
import mock

import gather_keys_cli

if sys.version_info[0] == 2:
input_patch = '__builtin__.raw_input'
else:
input_patch = 'builtins.input'

class TestGatherKeysCLI(unittest.TestCase):

@mock.patch('gather_keys_cli.webbrowser.open')
@mock.patch('gather_keys_cli.FitbitOauthClient')
@mock.patch('__builtin__.raw_input') # Python 2.7 input
@mock.patch(input_patch)
def test_gather_keys_success(self, mock_raw_input, mock_client_cls, mock_browser):
"""
Test successful OAuth flow in gather_keys()
Expand Down
2 changes: 2 additions & 0 deletions requirements/python3_django111/base.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
python-dateutil>2.6
requests-oauthlib==2.0.0
5 changes: 5 additions & 0 deletions requirements/python3_django111/dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-r base.txt
-r test.txt

cherrypy==18.10.0
tox
7 changes: 7 additions & 0 deletions requirements/python3_django111/test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
mock==5.2.0
coverage==7.2.7
Sphinx<5
tox
requests==2.31.0
requests-oauthlib==2.0.0
cherrypy==18.10.0
9 changes: 7 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
import re

from setuptools import setup

required = [line for line in open('requirements/django18/base.txt').read().split("\n") if line != '']
required_test = [line for line in open('requirements/django18/test.txt').read().split("\n") if not line.startswith("-r") and line != '']
if sys.version_info[0] < 3:
required = [line for line in open('requirements/django18/base.txt').read().split("\n") if line != '']
required_test = [line for line in open('requirements/django18/test.txt').read().split("\n") if not line.startswith("-r") and line != '']
else:
required = [line for line in open('requirements/python3_django111/base.txt').read().split("\n") if line != '']
required_test = [line for line in open('requirements/python3_django111/test.txt').read().split("\n") if not line.startswith("-r") and line != '']

fbinit = open('fitbit/__init__.py').read()
author = re.search("__author__ = '([^']+)'", fbinit).group(1)
Expand Down