Exemple #1
0
 def test_encode_without_country(self):
     encoder = JSONSnippetEncoder()
     data = {
         'id': 99,
         'text': 'test-text',
         'icon': 'test-icon',
         'url': 'test-url',
         'weight': 100
     }
     snippet = JSONSnippetFactory.build(**data)
     result = encoder.default(snippet)
     eq_(result, data)
Exemple #2
0
 def test_encode_jsonsnippet(self):
     encoder = JSONSnippetEncoder()
     data = {
         'id': 99,
         'text': 'test-text',
         'icon': 'test-icon',
         'url': 'test-url',
         'countries': ['US', 'GR'],
         'weight': 100
     }
     snippet = JSONSnippetFactory.create(**data)
     result = encoder.default(snippet)
     eq_(result.pop('target_geo'), result.get('countries')[0])
     eq_(set(result.pop('countries')), set(data.pop('countries')))
     eq_(result, data)
Exemple #3
0
 def test_encode_other(self, default_mock):
     encoder = JSONSnippetEncoder()
     data = {'id': 3}
     encoder.default(data)
     default_mock.assert_called_with(data)