-
-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed merge issue with requirements. The git link appears broken, usi…
…ng pypi instead
- Loading branch information
Showing
63 changed files
with
1,561 additions
and
770 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ collected_static/ | |
testing/ | ||
env/ | ||
htmlcov | ||
*.tar.gz | ||
|
||
.mypy_cache/ | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -154,6 +154,6 @@ gpg --sender "User Name <[email protected]>" --detach-sign sitestatic/netboot/*. | |
|
||
# Production Installation | ||
|
||
Arch Linux has an Ansible role for Archweb in their [infrastructure repo](https://git.archlinux.org/infrastructure.git/). | ||
Arch Linux has an Ansible role for Archweb in their [infrastructure repo](https://gitlab.archlinux.org/archlinux/infrastructure). | ||
|
||
vim: set syntax=markdown et: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
devel/migrations/0008_alter_userprofile_repos_auth_token_and_more.py
Large diffs are not rendered by default.
Oops, something went wrong.
647 changes: 647 additions & 0 deletions
647
devel/migrations/0009_alter_userprofile_time_zone_alter_userprofile_yob.py
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from django.conf import settings | ||
|
||
|
||
def mastodon_link(request): | ||
return {'MASTODON_LINK': getattr(settings, "MASTODON_LINK", "")} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,80 +1,76 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
import sys | ||
from email.header import Header | ||
from email.message import Message | ||
from io import StringIO | ||
from tempfile import mkdtemp | ||
|
||
from django.test import TransactionTestCase | ||
import pytest | ||
|
||
from django.core.management import call_command | ||
from django.core.management.base import CommandError | ||
|
||
from main.models import Donor | ||
from main.management.commands.donor_import import Command | ||
|
||
|
||
class DonorImportTest(TransactionTestCase): | ||
|
||
def setUp(self): | ||
self.command = Command() | ||
|
||
def test_parse_subject(self): | ||
self.assertIsNone(self.command.parse_subject('garbage')) | ||
|
||
# Valid | ||
valid = u'Receipt [$25.00] By: John Doe [[email protected]]' | ||
output = self.command.parse_subject(valid) | ||
self.assertEqual(output, u'John Doe') | ||
|
||
def test_parse_name(self): | ||
self.assertEqual(self.command.sanitize_name(u'1244'), u'') | ||
self.assertEqual(self.command.sanitize_name(u'John Doe'), u'John Doe') | ||
self.assertEqual(self.command.sanitize_name(u' John Doe '), u'John Doe') | ||
self.assertEqual(self.command.sanitize_name(u'John Doe 23'), u'John Doe') | ||
|
||
def test_decode_subject(self): | ||
text = u'メイル' | ||
subject = Header(text, 'utf-8') | ||
self.assertEqual(self.command.decode_subject(subject), text) | ||
|
||
def test_invalid_args(self): | ||
stdin = sys.stdin | ||
with self.assertRaises(CommandError) as e: | ||
sys.stdin = StringIO('') | ||
call_command('donor_import') | ||
self.assertIn('Failed to read from STDIN', str(e.exception)) | ||
sys.stdin = stdin | ||
|
||
def test_invalid_path(self): | ||
with self.assertRaises(CommandError) as e: | ||
call_command('donor_import', '/tmp/non-existant') | ||
self.assertIn('argument input: can\'t open', str(e.exception)) | ||
|
||
def test_import(self): | ||
tmpmail = mkdtemp('archweb') + "/mail" | ||
|
||
msg = Message() | ||
msg['subject'] = 'John Doe' | ||
msg['to'] = 'John Doe <[email protected]>' | ||
with open(tmpmail, 'wb') as fp: | ||
fp.write(msg.as_bytes()) | ||
|
||
# Invalid | ||
with self.assertRaises(SystemExit): | ||
call_command('donor_import', tmpmail) | ||
self.assertEqual(len(Donor.objects.all()), 0) | ||
|
||
# Valid | ||
msg = Message() | ||
msg['subject'] = 'Receipt [$25.00] By: David Doe [[email protected]]' | ||
msg['to'] = 'John Doe <[email protected]>' | ||
with open(tmpmail, 'wb') as fp: | ||
fp.write(msg.as_bytes()) | ||
|
||
call_command('donor_import', tmpmail) | ||
self.assertEqual(len(Donor.objects.all()), 1) | ||
|
||
# Re-running should result in no new donor | ||
call_command('donor_import', tmpmail) | ||
self.assertEqual(len(Donor.objects.all()), 1) | ||
command = Command() | ||
|
||
|
||
def test_parse_subject(): | ||
assert command.parse_subject('garbage') is None | ||
|
||
# Valid | ||
valid = 'Receipt [$25.00] By: John Doe [[email protected]]' | ||
output = command.parse_subject(valid) | ||
assert output == 'John Doe' | ||
|
||
|
||
def test_parse_name(): | ||
assert command.sanitize_name('1244') == '' | ||
assert command.sanitize_name('John Doe') == 'John Doe' | ||
assert command.sanitize_name(' John Doe ') == 'John Doe' | ||
assert command.sanitize_name('John Doe 23') == 'John Doe' | ||
|
||
|
||
def test_decode_subject(): | ||
text = u'メイル' | ||
subject = Header(text, 'utf-8') | ||
assert command.decode_subject(subject) == text | ||
|
||
|
||
def test_invalid_args(monkeypatch): | ||
monkeypatch.setattr('sys.stdin', StringIO('')) | ||
with pytest.raises(CommandError) as e: | ||
call_command('donor_import') | ||
assert 'Failed to read from STDIN' in str(e.value) | ||
|
||
|
||
def test_invalid_path(): | ||
with pytest.raises(CommandError) as e: | ||
call_command('donor_import', '/tmp/non-existant') | ||
assert 'argument input: can\'t open' in str(e.value) | ||
|
||
|
||
def test_maildir(db, monkeypatch): | ||
msg = Message() | ||
msg['subject'] = 'John Doe' | ||
msg['to'] = 'John Doe <[email protected]>' | ||
|
||
# Invalid | ||
monkeypatch.setattr('sys.stdin', StringIO(msg.as_string())) | ||
with pytest.raises(SystemExit): | ||
call_command('donor_import') | ||
assert len(Donor.objects.all()) == 0 | ||
|
||
# # Valid | ||
msg = Message() | ||
msg['subject'] = 'Receipt [$25.00] By: David Doe [[email protected]]' | ||
msg['to'] = 'John Doe <[email protected]>' | ||
monkeypatch.setattr('sys.stdin', StringIO(msg.as_string())) | ||
call_command('donor_import') | ||
assert len(Donor.objects.all()) == 1 | ||
|
||
# # Re-running should result in no new donor | ||
monkeypatch.setattr('sys.stdin', StringIO(msg.as_string())) | ||
call_command('donor_import') | ||
assert len(Donor.objects.all()) == 1 |
Oops, something went wrong.