示例#1
0
    def test_fetch_list_fails(self):
        self.run_api_call.side_effect = Exception("DEADBEEF")

        with self.assertRaises(api_interface.FetchInformationFailed) as cm:
            api_interface.fetch_plans(Mock())

        the_exception = cm.exception
        self.assertEqual(str(the_exception), "DEADBEEF")
示例#2
0
    def test_fetch_plans_empty_fails(self):
        ret_val = []

        self.run_api_call.return_value = ret_val

        with self.assertRaises(api_interface.FetchInformationFailed) as cm:
            result = api_interface.fetch_plans(Mock())

        the_exception = cm.exception
        self.assertEqual(str(the_exception), api_interface.NO_PLANS)
示例#3
0
    def test_fetch_list_succeeds(self):
        ret_val = [{'group_id': sentinel.group_id1,
                    'storage_gigs' : sentinel.storage_gigs1,
                    },
                   {'group_id': sentinel.group_id2,
                    'storage_gigs' : sentinel.storage_gigs2
                    }]

        self.run_api_call.return_value = ret_val

        result = api_interface.fetch_plans(Mock())
        self.assertEqual(result, ret_val)