def setUp(self): self.fake_model = self.FakeFlowModel() self.fake_model_field = self.fake_model._meta.get_field('flow') self.field = FlowField(null=True) self.flow = Flow() self.pickle_str = _from_bytes(base64.b64encode(pickle.dumps( self.flow)))
class TestFlowField(unittest.TestCase): class FakeFlowModel(models.Model): flow = FlowField() def setUp(self): self.fake_model = self.FakeFlowModel() self.fake_model_field = self.fake_model._meta.get_field('flow') self.field = FlowField() self.flow = Flow() self.pickle_str = _from_bytes( base64.b64encode(pickle.dumps(self.flow))) def test_field_is_text(self): self.assertEquals(self.field.get_internal_type(), 'TextField') def test_field_unpickled(self): python_val = self.field.to_python(self.pickle_str) self.assertTrue(isinstance(python_val, Flow)) def test_field_pickled(self): prep_value = self.field.get_db_prep_value(self.flow, connection=None) self.assertEqual(prep_value, self.pickle_str) def test_field_value_to_string(self): self.fake_model.flow = self.flow value_str = self.fake_model_field.value_to_string(self.fake_model) self.assertEqual(value_str, self.pickle_str) def test_field_value_to_string_none(self): self.fake_model.flow = None value_str = self.fake_model_field.value_to_string(self.fake_model) self.assertEqual(value_str, None)
class TestFlowField(unittest.TestCase): class FakeFlowModel(models.Model): flow = FlowField() def setUp(self): self.fake_model = self.FakeFlowModel() self.fake_model_field = self.fake_model._meta.get_field('flow') self.field = FlowField() self.flow = Flow() self.pickle_str = _from_bytes(base64.b64encode(pickle.dumps( self.flow))) def test_field_is_text(self): self.assertEquals(self.field.get_internal_type(), 'TextField') def test_field_unpickled(self): python_val = self.field.to_python(self.pickle_str) self.assertTrue(isinstance(python_val, Flow)) def test_field_pickled(self): prep_value = self.field.get_db_prep_value(self.flow, connection=None) self.assertEqual(prep_value, self.pickle_str) def test_field_value_to_string(self): self.fake_model.flow = self.flow value_str = self.fake_model_field.value_to_string(self.fake_model) self.assertEqual(value_str, self.pickle_str) def test_field_value_to_string_none(self): self.fake_model.flow = None value_str = self.fake_model_field.value_to_string(self.fake_model) self.assertEqual(value_str, None)
def setUp(self): self.fake_model = self.FakeFlowModel() self.fake_model_field = self.fake_model._meta.get_field('flow') self.field = FlowField(null=True) self.flow = Flow() self.pickle_str = _from_bytes( base64.b64encode(pickle.dumps(self.flow)))
class FlowModel(models.Model): """ FlowModel stores temporary the flow information for authenticating a user for the Google APIs """ id = models.OneToOneField(LilyUser, primary_key=True) flow = FlowField()
class FlowModel(models.Model): id = models.ForeignKey(User, primary_key=True) flow = FlowField()
class FlowModel(models.Model): id = models.ForeignKey(AUTH_USER_MODEL, primary_key=True, on_delete=models.CASCADE) flow = FlowField()
def test_flow_with_null(self): flow = FlowField() self.assertTrue(flow.null)
class FakeFlowModel(models.Model): flow = FlowField()
class FlowModel(models.Model): id = models.OneToOneField(User, primary_key=True) flow = FlowField()