Skip to content

Commit

Permalink
Merge pull request #19 from ambitioninc/develop
Browse files Browse the repository at this point in the history
0.5.0
  • Loading branch information
somewes authored Jun 29, 2023
2 parents 1d48790 + 5219bdd commit f58987c
Show file tree
Hide file tree
Showing 15 changed files with 134 additions and 41 deletions.
3 changes: 2 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
include README.rst
include LICENSE
include LICENSE
recursive-include requirements *
5 changes: 5 additions & 0 deletions docs/release_notes.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Release Notes
=============

v0.5.0
------
* Django 3.2-4.2 support only
* py 3.7-3.9 only

v0.3.0
------
* Moved task definitions
Expand Down
7 changes: 7 additions & 0 deletions manage.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
#!/usr/bin/env python
import sys

# Show warnings about django deprecations - uncomment for version upgrade testing
import warnings
from django.utils.deprecation import RemovedInNextVersionWarning
warnings.filterwarnings('always', category=DeprecationWarning)
warnings.filterwarnings('always', category=PendingDeprecationWarning)
warnings.filterwarnings('always', category=RemovedInNextVersionWarning)

from settings import configure_settings


Expand Down
2 changes: 0 additions & 2 deletions newrelic_plugin_agent/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
# flake8: noqa
from .version import __version__

default_app_config = 'newrelic_plugin_agent.apps.NewrelicPluginAgentConfig'
37 changes: 37 additions & 0 deletions newrelic_plugin_agent/migrations/0001_0002_squashed.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Generated by Django 3.2.19 on 2023-06-02 15:38

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

replaces = [('newrelic_plugin_agent', '0001_initial'),
('newrelic_plugin_agent', '0002_migrate_jsonfield')]

dependencies = [
]

operations = [
migrations.CreateModel(
name='NewRelicComponent',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('guid', models.CharField(max_length=64)),
('name', models.CharField(max_length=32)),
('last_pushed_time', models.DateTimeField()),
],
),
migrations.CreateModel(
name='NewRelicMetricTimeslice',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('guid', models.CharField(max_length=256)),
('values', models.JSONField()),
('new_relic_component', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='metric_timeslices', to='newrelic_plugin_agent.newreliccomponent')),
],
options={
'unique_together': {('new_relic_component', 'guid')},
},
),
]
4 changes: 1 addition & 3 deletions newrelic_plugin_agent/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.2 on 2016-04-15 14:56
from __future__ import unicode_literals

from django.db import migrations, models
import django.db.models.deletion
import jsonfield.fields


class Migration(migrations.Migration):
Expand All @@ -29,7 +27,7 @@ class Migration(migrations.Migration):
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('guid', models.CharField(max_length=256)),
('values', jsonfield.fields.JSONField()),
('values', models.JSONField()),
('new_relic_component', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='metric_timeslices', to='newrelic_plugin_agent.NewRelicComponent')),
],
),
Expand Down
18 changes: 18 additions & 0 deletions newrelic_plugin_agent/migrations/0002_migrate_jsonfield.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.0.10 on 2023-06-02 15:27

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('newrelic_plugin_agent', '0001_initial'),
]

operations = [
migrations.AlterField(
model_name='newrelicmetrictimeslice',
name='values',
field=models.JSONField(),
),
]
3 changes: 1 addition & 2 deletions newrelic_plugin_agent/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from manager_utils import ManagerUtilsManager
from django.db import models
from jsonfield import JSONField


class NewRelicComponent(models.Model):
Expand Down Expand Up @@ -139,7 +138,7 @@ class NewRelicMetricTimeslice(models.Model):
guid = models.CharField(max_length=256)
# the metric timeslice values
# https://docs.newrelic.com/docs/plugins/plugin-developer-resources/developer-reference/metric-data-plugin-api#timeslice
values = JSONField()
values = models.JSONField()

class Meta:
unique_together = ('new_relic_component', 'guid')
Expand Down
2 changes: 1 addition & 1 deletion newrelic_plugin_agent/tests/conf_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def test_defaults(self):
self.assertEqual(settings.NEWRELIC_BASE_URL, DEFAULTS['NEWRELIC_BASE_URL'])
self.assertEqual(settings.NEWRELIC_LICENSE_KEY, DEFAULTS['NEWRELIC_LICENSE_KEY'])
with self.assertRaises(AttributeError):
assert(settings.FOO)
assert settings.FOO

@override_settings(
NEWRELIC_PLUGIN_AGENT={'TIMESLICE_LOCK_RETRY_DELAY_MS': 500})
Expand Down
2 changes: 1 addition & 1 deletion newrelic_plugin_agent/tests/models_tests.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.test import TestCase
from django_dynamic_fixture import G
from mock import patch
from unittest.mock import patch
from manager_utils import ManagerUtilsManager

from newrelic_plugin_agent.models import NewRelicMetricTimeslice, NewRelicComponent
Expand Down
2 changes: 1 addition & 1 deletion newrelic_plugin_agent/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.3.0'
__version__ = '0.5.0'
5 changes: 5 additions & 0 deletions requirements/requirements-testing.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
psycopg2
coverage
django-dynamic-fixture
django-nose
flake8
2 changes: 2 additions & 0 deletions requirements/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Django>=3.2,<5
django-manager-utils>=3.1.0
47 changes: 36 additions & 11 deletions settings.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import json

from django.conf import settings

Expand All @@ -9,20 +10,22 @@ def configure_settings():
"""
if not settings.configured:
# Determine the database settings depending on if a test_db var is set in CI mode or not
test_db = os.environ.get('DB', None)
test_db = os.environ.get('DB', 'postgres')
if test_db is None:
db_config = {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'ambition_dev',
'USER': 'ambition_dev',
'PASSWORD': 'ambition_dev',
'HOST': 'localhost'
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'newrelic_plugin_agent',
'USER': 'postgres',
'PASSWORD': '',
'HOST': 'db'
}
elif test_db == 'postgres':
db_config = {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'USER': 'postgres',
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'newrelic_plugin_agent',
'USER': 'postgres',
'PASSWORD': '',
'HOST': 'db'
}
elif test_db == 'sqlite':
db_config = {
Expand All @@ -32,7 +35,13 @@ def configure_settings():
else:
raise RuntimeError('Unsupported test DB {0}'.format(test_db))

# Check env for db override (used for github actions)
if os.environ.get('DB_SETTINGS'):
db_config = json.loads(os.environ.get('DB_SETTINGS'))

settings.configure(
SECRET_KEY='*',
DEFAULT_AUTO_FIELD='django.db.models.AutoField',
TEST_RUNNER='django_nose.NoseTestSuiteRunner',
NOSE_ARGS=['--nocapture', '--nologcapture', '--verbosity=1'],
DATABASES={
Expand All @@ -42,12 +51,28 @@ def configure_settings():
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.admin',
'newrelic_plugin_agent',
'newrelic_plugin_agent.tests',
),
ROOT_URLCONF='newrelic_plugin_agent.urls',
DEBUG=False,
MIDDLEWARE_CLASSES=(),
DDF_FILL_NULLABLE_FIELDS=False,
MIDDLEWARE=(
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware'
),
TEMPLATES=[
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
}
}
],
)
36 changes: 17 additions & 19 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ def get_version():
raise RuntimeError('Unable to find version string in {0}.'.format(VERSION_FILE))


def get_lines(file_path):
return open(file_path, 'r').read().split('\n')


install_requires = get_lines('requirements/requirements.txt')
tests_require = get_lines('requirements/requirements-testing.txt')


setup(
name='django-newrelic-plugin-agent',
version=get_version(),
Expand All @@ -30,30 +38,20 @@ def get_version():
packages=find_packages(),
classifiers=[
'Programming Language :: Python',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Framework :: Django :: 1.8',
'Framework :: Django :: 1.9'
'Framework :: Django :: 3.2',
'Framework :: Django :: 4.0',
'Framework :: Django :: 4.1',
'Framework :: Django :: 4.2',
],
license='MIT',
install_requires=[
'django>=1.8',
'django-manager-utils>=0.12.0',
'jsonfield>=0.9.23',
'django-db-mutex>=0.4.0',
],
tests_require=[
'freezegun>=0.2.8',
'psycopg2',
'django-nose',
'mock>=1.0.1',
'coverage>=3.7.1',
'django-dynamic-fixture',
],
install_requires=install_requires,
tests_require=tests_require,
test_suite='run_tests.run_tests',
include_package_data=True,
zip_safe=False,
Expand Down

0 comments on commit f58987c

Please sign in to comment.