Skip to content

Commit

Permalink
Merge branch 'release/0.2.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
banagale committed Aug 30, 2020
2 parents a44165e + a0c19ed commit f418af9
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 14 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Continuous Integration and Delivery

on: [push]

jobs:
run_tests_master:
if: github.ref == 'refs/heads/master'
name: Run Django-Address Tests on master
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1
with:
ref: 'refs/heads/master'
- name: Set up Python 3.8.5
uses: actions/setup-python@v1
with:
python-version: 3.8.5
- name: Install dependencies
run: pip install -r example_site/requirements.txt
- name: Run tests
run: python example_site/manage.py test example_site/
env:
SYSTEM_ENV: GITHUB_WORKFLOW

run_tests_develop:
if: github.ref == 'refs/heads/develop'
name: Run Django-Address Tests on develop
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1
with:
ref: 'refs/heads/develop'
- name: Set up Python 3.8.5
uses: actions/setup-python@v1
with:
python-version: 3.8.5
- name: Install dependencies
run: pip install -r example_site/requirements.txt
- name: Run tests
run: python example_site/manage.py test example_site/
env:
SYSTEM_ENV: GITHUB_WORKFLOW

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
*.log
*.pot
*.pyc
secret_const.py
__pycache__/
local_settings.py
db.sqlite3
Expand Down
25 changes: 23 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ INSTALLED_APPS = [
]
```

You wil need to add your Google Maps API key to `settings.py` too:
You can either store your Google API key in an environment variable as `GOOGLE_API_KEY` or you can
specify the key in `settings.py`. If you have an environment variable set it will override what you put in settings.py.:
```
GOOGLE_API_KEY = 'AIzaSyD--your-google-maps-key-SjQBE'
```
Expand Down Expand Up @@ -188,6 +189,26 @@ The template:
</body>
```

## Running Django-Address Tests
Django-address currently has partial form and model test coverage using `django.test.TestCase`.

To run the current tests:

1. [Clone](https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/cloning-a-repository) `django-address` locally.
1. Navigate to the example site, . `/django-address/example_site`
1. Create a [virtual environment](https://www.tangowithdjango.com/book17/chapters/requirements.html#virtual-environments) and install the example site dependencies. For example:

```
mkvirtualenv -p python3 django-address
pip install -r requirements.txt
```
1. Run `./manage.py test`

## Important note regarding US Territories
Django-address does not currently support the parsing of US territories aka Protectorates such as Guam or Puerto Rico.

This topic is under active consideration and its status is described in [#82](https://github.com/furious-luke/django-address/issues/82)

## Project Status Notes

This library was created by [Luke Hodkinson](@furious-luke) originally focused on Australian addresses.
Expand All @@ -197,6 +218,6 @@ In 2015 Luke began working to abstract the project so it could handle a wider va
This became the current `dev` branch. While good progress was made on this, the branch became stale and releases
continued under the current model architecture on master.

The project is currently in triage, read more about the project path forward [in this issue](#98).
The project is currently in open development, read more about the project status [in this issue](#98).

If you have questions, bug reports or suggestions please create a New Issue for the project.
18 changes: 18 additions & 0 deletions address/migrations/0003_auto_20200830_1851.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.1 on 2020-08-30 18:51

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('address', '0002_auto_20160213_1726'),
]

operations = [
migrations.AlterField(
model_name='state',
name='code',
field=models.CharField(blank=True, max_length=8),
),
]
3 changes: 1 addition & 2 deletions address/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def __str__(self):

class State(models.Model):
name = models.CharField(max_length=165, blank=True)
code = models.CharField(max_length=3, blank=True)
code = models.CharField(max_length=8, blank=True)
country = models.ForeignKey(Country, on_delete=models.CASCADE, related_name='states')

class Meta:
Expand Down Expand Up @@ -247,7 +247,6 @@ class Address(models.Model):
class Meta:
verbose_name_plural = 'Addresses'
ordering = ('locality', 'route', 'street_number')
# unique_together = ('locality', 'route', 'street_number')

def __str__(self):
if self.formatted != '':
Expand Down
9 changes: 3 additions & 6 deletions address/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,6 @@ def test_ordering(self):
self.assertEqual(qs[3].name, 'Northcote')
self.assertEqual(qs[4].name, 'Melbourne')

def test_unique_name_state(self):
Locality.objects.create(name='Melbourne', state=self.au_qld)
self.assertRaises(IntegrityError, Locality.objects.create, name='Melbourne', state=self.au_vic)

def test_unicode(self):
self.assertEqual(unicode(self.au_vic_mel), u'Melbourne, Victoria 3000, Australia')
self.assertEqual(unicode(self.au_vic_ftz), u'Fitzroy, Victoria, Australia')
Expand Down Expand Up @@ -274,7 +270,7 @@ def test_assignment_from_dict_duplicate_state_code(self):
self.assertEqual(self.test.address.route, 'Somewhere Street')
self.assertEqual(self.test.address.locality.name, 'Northcote')
self.assertEqual(self.test.address.locality.state.name, 'Victoria')
self.assertEqual(self.test.address.locality.state.code, '')
self.assertEqual(self.test.address.locality.state.code, 'Victoria')
self.assertEqual(self.test.address.locality.state.country.name, 'Australia')

def test_assignment_from_dict_invalid_country_code(self):
Expand All @@ -296,9 +292,10 @@ def test_assignment_from_dict_invalid_state_code(self):
'route': 'Somewhere Street',
'locality': 'Northcote',
'state': 'Victoria',
'state_code': 'Something else',
'state_code': 'Something',
'country': 'Australia',
}
# This is invalid because state codes are expected to have a max of 8 characters
self.assertRaises(ValueError, to_python, ad)

def test_assignment_from_string(self):
Expand Down
2 changes: 1 addition & 1 deletion example_site/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ This is hidden under Google Cloud Platform's console menu, under
* Google Maps _Places API_

### Update this example_site django project's [settings.py].
* Add your key to `GOOGLE_API_KEY`
* Add your key to `GOOGLE_API_KEY` or specify `GOOGLE_API_KEY` in your environment variables.

## Migrate
* `python manage.py migrate`
Expand Down
6 changes: 4 additions & 2 deletions example_site/example_site/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,10 @@

WSGI_APPLICATION = 'example_site.wsgi.application'


GOOGLE_API_KEY = ''
# Specify your Google API key as environment variable GOOGLE_API_KEY
# You may also specify it here, though be sure not to commit it to a repository
GOOGLE_API_KEY = '' # Specify your Google API key here
GOOGLE_API_KEY = os.environ.get('GOOGLE_API_KEY', GOOGLE_API_KEY)

# Database
# https://docs.djangoproject.com/en/dev/ref/settings/#databases
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from setuptools import find_packages, setup

version = '0.2.4'
version = '0.2.5'

if sys.argv[-1] == 'tag':
print("Tagging the version on github:")
Expand Down

0 comments on commit f418af9

Please sign in to comment.