def test_js_format_model(self): model_mock = Mock(spec=Model) model_mock.pk = 129 memberOf = MemberOf([True, model_mock, 0]) self.assertEqual( memberOf.get_js_format(), ["memberOf", [True, "129", "0"]] )
def test_js_format_date(self): memberOf = MemberOf([1, date(2010, 02, 19), "3"]) self.assertEqual( memberOf.get_js_format(), ["memberOf", ["1", "2010-02-19", "3"]] )
def test_python_condition_date(self): memberOf = MemberOf([1, date(2010, 03, 19), 5]) self.assertTrue(memberOf.met("2010-03-19")) self.assertTrue(memberOf.met(date(2010, 03, 19))) self.assertFalse(memberOf.met("2010-03-18")) self.assertFalse(memberOf.met(date(2010, 02, 19)))
def test_js_format_simple(self): memberOf = MemberOf([1, True, "3"]) self.assertEqual( memberOf.get_js_format(), ["memberOf", ["1", True, "3"]] )
def test_python_condition(self): memberOf = MemberOf([1, 2, 5, date(2010, 03, 19)]) self.assertTrue(memberOf.met("2")) self.assertTrue(memberOf.met(5)) self.assertFalse(memberOf.met(3)) self.assertFalse(memberOf.met(None))