def test_default_order(self): org = OrganizationFactory(mnemonic='org-1') source = OrganizationSourceFactory(organization=org) user = UserProfileFactory(username='******') org_pin1 = Pin(organization=org, resource=source) org_pin1.save() self.assertEqual(org_pin1.order, 0) org_pin2 = Pin( organization=org, resource=OrganizationCollectionFactory(organization=org)) org_pin2.save() self.assertEqual(org_pin2.order, 1) org_pin2.delete() org_pin3 = Pin( organization=org, resource=OrganizationCollectionFactory(organization=org)) org_pin3.save() self.assertEqual(org_pin3.order, 1) user_pin1 = Pin(user=user, resource=source) user_pin1.save() self.assertEqual(user_pin1.order, 0) user_pin2 = Pin( user=user, resource=OrganizationCollectionFactory(organization=org)) user_pin2.save() self.assertEqual(user_pin2.order, 1) user_pin2.delete() user_pin3 = Pin( user=user, resource=OrganizationCollectionFactory(organization=org)) user_pin3.save() self.assertEqual(user_pin3.order, 1)
def test_soft_delete(self): pin = Pin() pin.delete = Mock(return_value=True) self.assertEqual(pin.soft_delete(), True) pin.delete.assert_called_once()