cc1  v2.1
CC1 source code docs
 All Classes Namespaces Files Functions Variables Pages
image_test.py
Go to the documentation of this file.
1 # -*- coding: utf-8 -*-
2 # @COPYRIGHT_begin
3 #
4 # Copyright [2010-2014] Institute of Nuclear Physics PAN, Krakow, Poland
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 #
10 # http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 #
18 # @COPYRIGHT_end
19 
20 ##
21 # @package src.ec2.image_test
22 # @copyright Copyright (c) 2012 Institute of Nuclear Physics PAS <http://www.ifj.edu.pl/>
23 # @author Oleksandr Gituliar <gituliar@gmail.com>
24 #
25 
26 from ec2.base.action import Action
27 from ec2.base.test import TestCase
28 
29 
30 class ImageTestCase(TestCase):
31 
33  self.cluster_manager.image.user.list.side_effect = [
34  [{
35  'description': 'Fake image 01.',
36  'id': 123,
37  'name': 'image 01',
38  'platform': 2,
39  'state': 0,
40  'user_id': 1,
41 
42  }],
43  [{
44  'description': 'Fake image 02.',
45  'id': 456,
46  'name': 'image 02',
47  'platform': 2,
48  'state': 0,
49  'user_id': 1,
50  }],
51 
52  ]
53  action = Action({'Action': 'DescribeImages'}, self.cluster_manager)
54  response = action.execute()
55 
56  self.assertMultiLineEqual(
57  response,
58  """<?xml version="1.0" encoding="UTF-8"?>
59  <DescribeImagesResponse xmlns="http://ec2.amazonaws.com/doc/2012-03-01/">
60  <requestId>833f0802-7b29-4641-b953-6f6b78908b22</requestId>
61  <imagesSet>
62  <item>
63  <architecture>x86_64</architecture>
64  <description>Fake image 01.</description>
65  <imageId>123</imageId>
66  <imageLocation>ami-123</imageLocation>
67  <imageState>available</imageState>
68  <imageOwnerId>1</imageOwnerId>
69  <isPublic>false</isPublic>
70  <name>image 01</name>
71  <platform></platform>
72  </item>
73  <item>
74  <architecture>x86_64</architecture>
75  <description>Fake image 02.</description>
76  <imageId>456</imageId>
77  <imageLocation>ami-456</imageLocation>
78  <imageState>available</imageState>
79  <imageOwnerId>1</imageOwnerId>
80  <isPublic>true</isPublic>
81  <name>image 02</name>
82  <platform></platform>
83  </item>
84  </imagesSet>
85  </DescribeImagesResponse>
86  """
87  )
88