Commit 8a9af388 authored by Giorgos Korfiatis's avatar Giorgos Korfiatis Committed by Christos Stavrakakis
Browse files

astakos: Include unicode strings in tests

parent 4bcec8a8
# -*- coding: utf-8 -*-
# Copyright 2011-2014 GRNET S.A. All rights reserved.
#
# Redistribution and use in source and binary forms, with or
......@@ -60,15 +61,15 @@ class QuotaAPITest(TestCase):
component1 = Component.objects.create(name="comp1")
register.add_service(component1, "service1", "type1", [])
# custom service resources
resource11 = {"name": "service1.resource11",
"desc": "resource11 desc",
resource11 = {"name": u"service1.ρίσορς11",
"desc": "ρίσορς11 desc",
"service_type": "type1",
"service_origin": "service1",
"ui_visible": True}
r, _ = register.add_resource(resource11)
register.update_base_default(r, 100)
resource12 = {"name": "service1.resource12",
"desc": "resource11 desc",
"desc": "ρίσορς11 desc",
"service_type": "type1",
"service_origin": "service1",
"unit": "bytes"}
......@@ -88,7 +89,7 @@ class QuotaAPITest(TestCase):
register.add_service(component2, "service2", "type2", [])
# create another service
resource21 = {"name": "service2.resource21",
"desc": "resource11 desc",
"desc": "ρίσορς11 desc",
"service_type": "type2",
"service_origin": "service2",
"ui_visible": False}
......@@ -169,7 +170,7 @@ class QuotaAPITest(TestCase):
commission_request = {
"force": False,
"auto_accept": False,
"name": "my commission",
"name": u"ναμε",
"provisions": [
{
"holder": "user:" + user.uuid,
......@@ -218,8 +219,10 @@ class QuotaAPITest(TestCase):
body = json.loads(r.content)
self.assertEqual(body['serial'], serial1)
assertIn('issue_time', body)
self.assertEqual(body["name"], u"ναμε")
provisions = sorted(body['provisions'], key=lambda p: p['resource'])
self.assertEqual(provisions, commission_request['provisions'])
crp = sorted(commission_request['provisions'], key=lambda p: p['resource'])
self.assertEqual(provisions, crp)
self.assertEqual(body['name'], commission_request['name'])
r = client.get(u('service_quotas?user=' + user.uuid), **s1_headers)
......@@ -303,7 +306,7 @@ class QuotaAPITest(TestCase):
commission_request = {
"auto_accept": True,
"name": "my commission",
"name": "κομίσσιον",
"provisions": "dummy"}
post_data = json.dumps(commission_request)
......
# -*- coding: utf-8 -*-
# Copyright 2011-2014 GRNET S.A. All rights reserved.
#
# Redistribution and use in source and binary forms, with or
......@@ -49,19 +50,19 @@ class ProjectAPITest(TestCase):
def setUp(self):
self.client = Client()
component1 = Component.objects.create(name="comp1")
register.add_service(component1, "service1", "type1", [])
register.add_service(component1, "σέρβις1", "type1", [])
# custom service resources
resource11 = {"name": "service1.resource11",
"desc": "resource11 desc",
resource11 = {"name": u"σέρβις1.ρίσορς11",
"desc": u"ρίσορς11 desc",
"service_type": "type1",
"service_origin": "service1",
"service_origin": u"σέρβις1",
"ui_visible": True}
r, _ = register.add_resource(resource11)
register.update_base_default(r, 100)
resource12 = {"name": "service1.resource12",
"desc": "resource11 desc",
resource12 = {"name": u"σέρβις1.resource12",
"desc": "resource12 desc",
"service_type": "type1",
"service_origin": "service1",
"service_origin": u"σέρβις1",
"unit": "bytes"}
r, _ = register.add_resource(resource12)
register.update_base_default(r, 1024)
......@@ -162,10 +163,11 @@ class ProjectAPITest(TestCase):
self.assertEqual(status, 409)
app1 = {"name": "test.pr",
"description": u"δεσκρίπτιον",
"end_date": "2013-5-5T20:20:20Z",
"join_policy": "auto",
"max_members": 5,
"resources": {"service1.resource11": {
"resources": {u"σέρβις1.ρίσορς11": {
"project_capacity": 1024,
"member_capacity": 512}}
}
......@@ -190,6 +192,7 @@ class ProjectAPITest(TestCase):
self.assertEqual(body["last_application"]["state"], "pending")
self.assertEqual(body["state"], "uninitialized")
self.assertEqual(body["owner"], self.user1.uuid)
self.assertEqual(body["description"], u"δεσκρίπτιον")
# Approve forbidden
status = self.project_action(project_id, "approve", app_id=app_id,
......@@ -233,7 +236,7 @@ class ProjectAPITest(TestCase):
"join_policy": "moderated",
"leave_policy": "auto",
"max_members": 3,
"resources": {"service1.resource11": {
"resources": {u"σέρβις1.ρίσορς11": {
"project_capacity": 1024,
"member_capacity": 1024}}
}
......@@ -602,13 +605,13 @@ class ProjectAPITest(TestCase):
status, body = self.create(ap, h_owner)
self.assertEqual(status, 400)
ap["resources"] = {"service1.resource11": {
ap["resources"] = {u"σέρβις1.ρίσορς11": {
"member_capacity": 512}}
status, body = self.create(ap, h_owner)
self.assertEqual(status, 400)
ap["resources"] = {"service1.resource11": {"member_capacity": 512,
"project_capacity": 1024}}
ap["resources"] = {u"σέρβις1.ρίσορς11": {"member_capacity": 512,
"project_capacity": 1024}}
status, body = self.create(ap, h_owner)
self.assertEqual(status, 201)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment