Exemple #1
0
 def setUp(self):
     self.msisdn = '1234567890'
     self.pin = '1234'
     self.fba = utils.create_fba(msisdn=self.msisdn)
     identity = self.fba.actor.get_identity(self.msisdn)
     identity.set_pin(self.pin)
     identity.save()
     self.login()
    def test_fba_farmer_registration(self):
        fba1 = utils.create_fba(msisdn='0')
        fba2 = utils.create_fba(msisdn='1')
        farmer1 = utils.create_farmer(msisdn='1234', name='farmer1')
        farmer2 = utils.create_farmer(msisdn='5678', name='farmer2')

        # Each should register 1 farmer first
        fba1.register_farmer(farmer1)
        fba2.register_farmer(farmer2)
        # Then the second farmer
        fba1.register_farmer(farmer2)
        fba2.register_farmer(farmer1)

        # both should 'know' each farmer
        farmers = set([farmer1, farmer2])
        self.assertEqual(farmers, set(fba1.get_farmers()))
        self.assertEqual(farmers, set(fba2.get_farmers()))

        # Each should only have 1 farmer as a registered farmer
        self.assertEqual([farmer1], list(fba1.get_registered_farmers()))
        self.assertEqual([farmer2], list(fba2.get_registered_farmers()))
 def test_fba_role(self):
     fba = utils.create_fba()
     self.assertEquals(fba.farmers.count(), 0)