Example #1
0
    def test_farmer_creation(self):
        self.assertFalse(utils.is_farmer(self.test_msisdn))
        response = self.client.get(reverse('fncs:farmer_new'))
        self.assertEqual(response.status_code, 200)
        response = self.client.post(reverse('fncs:farmer_new'), {
            'msisdn1': self.test_msisdn,
            'name': 'name',
            'surname': 'surname',
            'markets': [self.market.pk],
            'gender': "M",
        })
        farmer = Farmer.objects.get(actor__user__username=self.test_msisdn)
        self.assertEqual(farmer.actor.user.first_name, 'name')
        self.assertEqual(farmer.actor.user.last_name, 'surname')
        self.assertEqual(farmer.gender, 'M')

        self.assertEqual(response.status_code, 302)
        self.assertTrue(utils.is_farmer(self.test_msisdn))
Example #2
0
 def test_farmer_matching_on_msisdn(self):
     farmer = utils.create_farmer()
     msisdn = farmer.actor.get_msisdns()[0]
     self.assertTrue(utils.is_farmer(msisdn))
     # Now we try & recreate a farmer with a known MSISDN, should give us a
     # matching suggestion
     response = self.client.post(reverse('fncs:farmer_new'), {
         'msisdn1': msisdn,
         'name': 'name',
         'surname': 'surname',
         'markets': [self.market.pk],
         'gender': 'M',
     })
     self.assertEqual(response.status_code, 200)
     self.assertContains(response, farmer.actor.name)