Diferencia entre revisiones de «Link2»

De Wiki de EGC
Saltar a: navegación, buscar
(Página creada con «<source> def testCreateVotinAPI(self): self.login() data = { 'name': 'Example', 'desc': 'Description example', 'question...»)
 
 
Línea 1: Línea 1:
<source>
+
<syntaxhighlight lang="python">
 
def testCreateVotinAPI(self):
 
def testCreateVotinAPI(self):
 
         self.login()
 
         self.login()
Línea 14: Línea 14:
 
         voting = Voting.objects.get(name='Example')
 
         voting = Voting.objects.get(name='Example')
 
         self.assertEqual(voting.desc, 'Description example')
 
         self.assertEqual(voting.desc, 'Description example')
</source>
+
</syntaxhighlight>

Revisión actual del 12:34 3 oct 2022

def testCreateVotinAPI(self):
        self.login()
        data = {
            'name': 'Example',
            'desc': 'Description example',
            'question': 'I want a ',
            'question_opt': ['cat', 'dog', 'horse']
        }

        response = self.client.post('/voting/', data, format='json')
        self.assertEqual(response.status_code, 201)

        voting = Voting.objects.get(name='Example')
        self.assertEqual(voting.desc, 'Description example')