def test_convert_contenttypes(self):
     out = jsmodels(applications=['contenttypes'])
     self.assertEquals(sorted(out['models'].keys()), ['ContentType'])
     self.assertEquals(
             list(filter(lambda x: x.get('name','')=='logentry',
                    out['models']['ContentType']['fields']))[0]['rel']['reverse_fk'],
             True)
Example #2
0
 def test_human_shortnames(self):
     out = jsmodels(applications=['test',])
     out = shortnames(out, mapping=MAPPING)
     self.assertTrue(
             filter(lambda x: 'short_name' in x,
                 out['models']['Person']['fields']))
     for field in out['models']['Person']['fields']:
         if field['field'] == 'CharField':
             self.assertEquals(field['short_name'], 'text')
Example #3
0
    def test_human_urls(self):
        self.assertTrue(reverse('person-list'))
        self.assertTrue(reverse('person-detail', kwargs=dict(pk=1)))

        out = jsmodels(applications=['test',], prepare=False)
        out = drf(out)

        f = get_field(out['models']['Account']['fields'], 'person')
        self.assertEqual(f['url']['id'], '/api/account/:id')
        f = get_field(out['models']['Account']['fields'], 'name')
        self.assertEqual(f['url']['id'], '/api/account/:id')
Example #4
0
 def test_human_shortnames(self):
     out = jsmodels(applications=[
         'test',
     ])
     out = shortnames(out, mapping=MAPPING)
     self.assertTrue(
         filter(lambda x: 'short_name' in x,
                out['models']['Person']['fields']))
     for field in out['models']['Person']['fields']:
         if field['field'] == 'CharField':
             self.assertEquals(field['short_name'], 'text')
Example #5
0
    def test_human_urls(self):
        self.assertTrue(reverse('person-list'))
        self.assertTrue(reverse('person-detail', kwargs=dict(pk=1)))

        out = jsmodels(applications=[
            'test',
        ], prepare=False)
        out = drf(out)

        f = get_field(out['models']['Account']['fields'], 'person')
        self.assertEqual(f['url']['id'], '/api/account/:id')
        f = get_field(out['models']['Account']['fields'], 'name')
        self.assertEqual(f['url']['id'], '/api/account/:id')
Example #6
0
 def test_implied_content_type(self):
     implied = [{
         'model': ContentType,
         'field': 'content_type',
         'relname': 'contenttype',
         'verbose_name': 'Content Type',}]
     out = jsmodels(applications=['test',])
     out = add_relations(out, implied)
     self.assertTrue(
             filter(lambda x: x['name'] =='content_type',
                 out['models']['Person']['fields']))
     self.assertTrue(
             filter(lambda x: x['name'] =='content_type',
                 out['models']['Computer']['fields']))
 def test_convert_test(self):
     out = jsmodels(applications=['test',])
     self.assertEquals(sorted(out['models'].keys()), ['Account', 'Computer', 'Person'])
     self.assertEquals(
             sorted([k['name'] for k in out['models']['Person']['fields']]),
             ['account', 'age','computers','created','id','name'])
Example #8
0
 def test_json(self):
     out = jsmodels(applications=['test',])
     self.assertTrue(to_json(out))