Skip to content

Commit

Permalink
Added wallet_info attribute
Browse files Browse the repository at this point in the history
Changed tasks and migrations
  • Loading branch information
mauler committed Jan 17, 2018
1 parent e6846c6 commit eae407d
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 10 deletions.
3 changes: 2 additions & 1 deletion meeting/gate/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,14 @@ class LocalTicketAdmin(admin.ModelAdmin):
list_display = ('wristband_code',
'entry_on',
'wallet_id',
'wallet_info',
'shop_created_on', )
list_filter = (
isnull_filter('wallet_id'),
'entry_on',
'shop_created_on',
)
search_fields = ('=wristband_code', )
search_fields = ('=wristband_code', 'wallet_info', )


@admin.register(GuestTicket)
Expand Down
23 changes: 23 additions & 0 deletions meeting/gate/migrations/0003_auto_20180117_1147.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 2.0.1 on 2018-01-17 11:47

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('gate', '0002_auto_20180111_0643'),
]

operations = [
migrations.AddField(
model_name='wristband',
name='wallet_info',
field=models.TextField(blank=True),
),
migrations.AlterField(
model_name='wristband',
name='wristband_code',
field=models.CharField(blank=True, db_index=True, error_messages={'unique': 'WBAND_CODE_EXISTS: Esta pulseira já foi registrada em nosso sistema.'}, max_length=10, null=True, unique=True, verbose_name='Pulseira'),
),
]
2 changes: 2 additions & 0 deletions meeting/gate/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ class Wristband(BaseModel):
verbose_name=_('ID Carteira')
)

wallet_info = models.TextField(blank=True)

shop_created_on = models.DateTimeField(verbose_name=_('Comprado em'),
blank=True,
null=True)
Expand Down
4 changes: 1 addition & 3 deletions meeting/gate/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,4 @@ def sync_wristband_wallet(wristband_code, entry_on, ticket, qrcode=None):
if r.status_code != status.HTTP_200_OK:
return None

data = r.json()

return data['id']
return r.json()
1 change: 1 addition & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ addopts =
-r fEsxXw
-vvv
--doctest-modules
--ignore build
--ignore meeting
--ignore setup.py
--ignore tests/test_browser.py
Expand Down
14 changes: 10 additions & 4 deletions tests/test_gate_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,20 @@

@pytest.fixture
def webticket():
return WebTicket.objects.create(wristband_code='1234567890')
return WebTicket.objects.create(wristband_code='1234567890',
person_name='Person',
person_document='DocumentId')


@pytest.mark.django_db
def test_sync_wristband_wallet_error(webticket, mocker):
WALLET_ID = 123
WALLET_INFO = 'Person (DocumentId)'
WALLET_DATA = {'wallet_id': WALLET_ID, 'wallet_info': WALLET_INFO}

mocker.patch('requests.put',
return_value=Mock(status_code=404,
json=Mock(return_value={'id': WALLET_ID})))
json=Mock(return_value=WALLET_DATA)))

assert sync_wristband_wallet(webticket.wristband_code,
timezone.now(),
Expand All @@ -28,11 +32,13 @@ def test_sync_wristband_wallet_error(webticket, mocker):
@pytest.mark.django_db
def test_sync_wristband_wallet_success(webticket, mocker):
WALLET_ID = 123
WALLET_INFO = 'Person (DocumentId)'
WALLET_DATA = {'wallet_id': WALLET_ID, 'wallet_info': WALLET_INFO}

mocker.patch('requests.put',
return_value=Mock(status_code=200,
json=Mock(return_value={'id': WALLET_ID})))
json=Mock(return_value=WALLET_DATA)))

assert sync_wristband_wallet(webticket.wristband_code,
timezone.now(),
webticket) == WALLET_ID
webticket) == WALLET_DATA
4 changes: 2 additions & 2 deletions tests/test_gate_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ def test_sell(self):
response = self.client.post(url,
{'wristband_code': self.WRISTBAND_CODE})
self.assertEqual(response.status_code, 200)
self.assertNotIn('WBAND_CODE_EXISTS', response.content)
self.assertNotIn(b'WBAND_CODE_EXISTS', response.content)

response = self.client.post(url,
{'wristband_code': self.WRISTBAND_CODE})
self.assertEqual(response.status_code, 200)
self.assertIn('WBAND_CODE_EXISTS', response.content)
self.assertIn(b'WBAND_CODE_EXISTS', response.content)

def test_index(self):
response = self.client.get(reverse('meeting-gate:index'))
Expand Down

0 comments on commit eae407d

Please sign in to comment.