Example #1
0
    def test_datetime_to_str(self):
        value = datetime_to_str(None)
        self.assertEqual(value, None)

        now = timezone.now()
        value = datetime_to_str(now)
        expected_value = datetime.strftime(now, "%Y-%m-%d %H:%M:%S")
        self.assertEqual(expected_value, value)
Example #2
0
    def test_datetime_to_str(self):
        value = datetime_to_str(None)
        self.assertEqual(value, None)

        from datetime import datetime
        now = datetime.now()
        value = datetime_to_str(now)
        expected_value = datetime.strftime(now, '%Y-%m-%d %H:%M:%S')
        self.assertEqual(expected_value, value)
Example #3
0
    def test_serialize_queryset(self):
        serialize_result = self.plan_serializer.serialize_queryset()
        self.assertEqual(len(self.plans), len(serialize_result))

        for plan in serialize_result:
            expected_plan = TestPlan.objects.get(pk=plan["id"])
            self.assertEqual(expected_plan.name, plan["name"])
            self.assertEqual(expected_plan.is_active, plan["is_active"])
            self.assertEqual(expected_plan.extra_link, plan["extra_link"])
            self.assertEqual(datetime_to_str(expected_plan.create_date),
                             plan["create_date"])
            self.assertEqual(expected_plan.author_id, plan["author_id"])
            self.assertEqual(expected_plan.author.username, plan["author"])
            self.assertEqual(expected_plan.product_version_id,
                             plan["product_version_id"])
            self.assertEqual(expected_plan.product_version.value,
                             plan["product_version"])
Example #4
0
    def test_serialize_queryset(self):
        serialize_result = self.plan_serializer.serialize_queryset()
        self.assertEqual(len(self.plans), len(serialize_result))

        for plan in serialize_result:
            plan_id = plan['plan_id']
            expected_plan = TestPlan.objects.get(pk=plan_id)
            self.assertEqual(expected_plan.name, plan['name'])
            self.assertEqual(expected_plan.is_active, plan['is_active'])
            self.assertEqual(expected_plan.extra_link, plan['extra_link'])
            self.assertEqual(datetime_to_str(expected_plan.create_date),
                             plan['create_date'])
            self.assertEqual(expected_plan.author_id, plan['author_id'])
            self.assertEqual(expected_plan.author.username, plan['author'])
            self.assertEqual(expected_plan.product_version_id,
                             plan['product_version_id'])
            self.assertEqual(expected_plan.product_version.value,
                             plan['product_version'])