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