- Update deploy job to use file variables
- Fix truncating values with exotic characters
This commit is contained in:
Sonny Bakker 2020-09-01 22:07:49 +02:00
parent b035526848
commit f0df342f61
4 changed files with 41 additions and 8 deletions

View file

@ -9,15 +9,12 @@ deploy:
before_script:
- pip install ansible --quiet
- git clone https://git.fudiggity.nl/sonny/ansible-playbooks.git deployment
- mkdir -p /root/.ssh
- echo "$DEPLOY_HOST_KEY" > /root/.ssh/known_hosts
- echo "$DEPLOY_KEY" > deployment/deploy_key && chmod 0600 deployment/deploy_key
- echo "$VAULT_PASSWORD" > deployment/vault && chmod 0600 deployment/vault
- mkdir /root/.ssh && echo "$DEPLOY_HOST_KEY" > /root/.ssh/known_hosts
script:
- >
ansible-playbook deployment/playbook.yml
--inventory deployment/apps.yml
--limit newsreader
--user ansible
--private-key deployment/deploy_key
--vault-password-file deployment/vault
--private-key "$DEPLOY_KEY"
--vault-password-file "$VAULT_FILE"

View file

@ -260,6 +260,27 @@ mock_with_long_title = {
]
}
mock_with_long_exotic_title = {
"entries": [
{
"author": "A. Author",
"id": "https://www.bbc.co.uk/news/world-us-canada-48338168",
"link": "https://www.bbc.co.uk/news/world-us-canada-48338168",
"published": "Mon, 20 May 2019 16:07:37 GMT",
"published_parsed": struct_time((2019, 5, 20, 16, 7, 37, 0, 140, 0)),
"summary": "Foreign Minister Mohammad Javad Zarif says the US "
"president should try showing Iranians some respect.",
"title": "#ഡെബ്കോണ്ഫ്20 ഓണ്‍ലൈന്‍ അവസാന ദിവസം മലയാളം"
"പരിപാടികളോടെയാണു് തുടങ്ങുന്നതു്: നെറ്റ്‌വര്‍ക്ക് വഴി കുറേ കമ്പ്യൂട്ടറുകളില്‍"
"എളുപ്പത്തില്‍ ഡെബിയന്‍ ഇന്‍സ്റ്റോള്‍ ചെയ്യാം (ഉച്ചക്ക് ശേഷം 2:30 നു്),"
"സ്വതന്ത്ര സോഫ്റ്റ്‌വെയറിൽ കേരളത്തിലെ സ്ത്രീകളുടെ പങ്കാളിത്തം (ഉച്ചക്ക്"
"ശേഷം 3:30 നു്), ഗ്നു/ലിനക്സും ഗെയ്മിങ്ങും (വൈകുന്നേരം 4:30 നു്),"
"കേരളത്തിലൊരു ഡെബ്കോൺഫ് (വൈകുന്നേരം 5:30 നു്) https://"
"debconf20.debconf.org/schedule/?block=7",
}
]
}
mock_with_longer_content_detail = {
"entries": [
{

View file

@ -361,6 +361,22 @@ class FeedBuilderTestCase(TestCase):
self.assertEquals(Post.objects.count(), 1)
self.assertEquals(len(post.title), 200)
self.assertTrue(post.title.endswith(""))
def test_long_title_exotic_title(self):
builder = FeedBuilder
rule = FeedFactory()
mock_stream = MagicMock(rule=rule)
with builder((mock_with_long_exotic_title, mock_stream)) as builder:
builder.save()
post = Post.objects.get()
self.assertEquals(Post.objects.count(), 1)
self.assertEquals(len(post.title), 200)
self.assertTrue(post.title.endswith(""))
def test_content_detail_is_prioritized_if_longer(self):
builder = FeedBuilder

View file

@ -2,7 +2,6 @@ from datetime import datetime
from django.conf import settings
from django.db.models.fields import CharField, TextField
from django.template.defaultfilters import truncatechars
from django.utils import timezone
import pytz
@ -66,6 +65,6 @@ def truncate_text(cls, field_name, value):
return value
if len(value) > max_length:
return truncatechars(value, max_length)
return f"{value[:max_length - 1]}"
return value