How to use app1 method in localstack

Best Python code snippet using localstack_python

test.py

Source:test.py Github

copy

Full Screen

1#!/usr/bin/python2# Licensed to the Apache Software Foundation (ASF) under one3# or more contributor license agreements. See the NOTICE file4# distributed with this work for additional information5# regarding copyright ownership. The ASF licenses this file6# to you under the Apache License, Version 2.0 (the7# "License"); you may not use this file except in compliance8# with the License. You may obtain a copy of the License at9# 10# http://www.apache.org/licenses/LICENSE-2.011# 12# Unless required by applicable law or agreed to in writing,13# software distributed under the License is distributed on an14# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY15# KIND, either express or implied. See the License for the16# specific language governing permissions and limitations17# under the License.18# Test the hosting server components19import sys20sys.debug = lambda *l: sys.stderr.write('python::debug ' + repr(l) + '\n')21from sys import debug22import time23time.strftime = lambda f, t: '2012-01-01T00:00:00+00:00'24try:25 import PIL26except:27 PIL = None28import unittest29from test.property import *30from test.reference import *31from test.cache import *32from util import *33from atomutil import *34import user35import accounts36import pictures37import pages38import icons39import composites40import apps41import store42import dashboards43import reviews44import ratings45import selector46import search47def testUser():48 # Return current user49 assert user.get((), mkprop('user', lambda: 'jdoe'), mkprop('email', lambda: 'jdoe@example.com'), mkprop('nick', lambda: 'jdoe'), mkprop('full', lambda: 'john doe'), mkprop('first', lambda: 'john'), mkprop('last', lambda: 'doe'), mkprop('realm', lambda: 'example.com'), mkprop('host', lambda: 'localhost')) == 'jdoe'50 return True51def testAccounts():52 # Get default account53 defaccount = (("'entry", ("'title", 'jdoe@example.com'), ("'id", 'jdoe@example.com'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-01T00:00:00+00:00'), ("'content",)),)54 assert accounts.get((), mkref('user', lambda id: 'jdoe@example.com'), mkcache('cache', {})) == defaccount55 # Get user's account56 jdoe = (("'entry", ("'title", 'John Doe'), ("'id", 'jdoe@example.com'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-01T00:00:00+00:00'), ("'content", ("'account", ("'email", 'jdoe@example.com'), ("'description", 'This is joe')))),)57 assert accounts.get((), mkref('user', lambda id: 'jdoe@example.com'), mkcache('cache', {('accounts', 'jdoe@example.com', 'user.account') : jdoe})) == jdoe58 # Put and get account59 cache1 = mkcache('cache', {('accounts', 'jdoe@example.com', 'user.account') : jdoe})60 jdoe1 = (("'entry", ("'title", 'John Doe'), ("'id", 'jdoe@example.com'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-01T00:00:00+00:00'), ("'content", ("'account", ("'email", 'bad@example.com'), ("'description", 'This is joe')))),)61 jdoe2 = (("'entry", ("'title", 'John Doe'), ("'id", 'jdoe@example.com'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-01T00:00:00+00:00'), ("'content", ("'account", ("'email", 'jdoe@example.com'), ("'description", 'This is joe again')))),)62 assert accounts.put((), jdoe1, mkref('user', lambda id: 'jdoe@example.com'), cache1) == True63 assert accounts.get((), mkref('user', lambda id: 'jdoe@example.com'), cache1) == jdoe64 assert accounts.put((), jdoe2, mkref('user', lambda id: 'jdoe@example.com'), cache1) == True65 assert accounts.get((), mkref('user', lambda id: 'jdoe@example.com'), cache1) == jdoe266 return True67def testPictures():68 if PIL is None:69 return True70 img16 = 'data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAOUlEQVQ4y2N0b3/7nwEH2FkpzGg7hQGn/OEcBkYmBgrBqAFUMIBiQDCeL3qY4ZTX33FqNB0Mj3QAAFC7Dhs7i7zzAAAAAElFTkSuQmCC'71 img50 = 'data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAACV0lEQVR4nO2YPU8UURSG3zMzO2wiIrguXwmthSEkJtBZmFgYG6n5Rf4VKmlILIw/YIstNgoVJhICy8zuyrIzy97vY6F8aH2LG3Of8hbnzZOZM5P70tsPI4ZHjKyr8ujwoN/7uD86+fK5tYXd9jb2WlvYpQSZjwwrUA17OBh0sX91jE8AkPgYHAJRJDSiSGhEkdCIIqERRUIjioRGFAmNKBIaUSQ0MiPryudAK+vaGSHYWQMA7GCcxsxKVESe7uwStdMQ7GBuz7Ly6PDAx/C7ECPF5LzXVXVZgMFqjPPqBzpsoUFIfWSwhqjP0NUTFLdn9Oz5m3c+ht+FOGtUXRayKvrqZjTMH2MlX8BaYwHL8PUqOxg1QaEm6OsaAwAgXxXNPzAzHBhMABFRQgB5DQCYmR0DDABZawu7XgMcjBzjQo1xpico2s18fbWZb7TnGutE5EXGOjalVBeXQp2NpL4EgKy9jT0fw29xCrPqFJ3r7zCmosFqM994uTj/anNxfieBnx0Rzs2+jacd6ypzJ+L7iViBylnoWYkTAVC7ma9vPnm083p58X1K5OU1nhpbWcf69Eac4M83N/O9I5QgowQp6PdOEEAJUZoSZb5EUqIsIUof7t1/80OMIqERRUIjioRGFAmNKBIaUSQ0okhoRJHQyKyA54Lu7/LMMhvp3GxqbOXrhnhjbS2dE5b5vqAb9uC1oHtYnjHApVDnX8fTjmHWCchL+SCdE8fX0+5I6fuCbukFvBZ0D8szU2P4dK6x0p5rrLXyhreCzjLMT6WLgVT9K2UGPmZGfPMLWsI5A943r6EAAAAASUVORK5CYII='72 # Put and get picture73 pic16 = (("'entry", ("'title", 'jdoe@example.com'), ("'id", 'jdoe@example.com'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-01T00:00:00+00:00'), ("'content", ("'picture", ("'image", img16)))),)74 pic50 = (("'entry", ("'title", 'jdoe@example.com'), ("'id", 'jdoe@example.com'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-01T00:00:00+00:00'), ("'content", ("'picture", ("'image", img50)))),)75 cache1 = mkcache('cache', {})76 assert pictures.put((), pic16, mkref('user', lambda id: 'jdoe@example.com'), cache1) == True77 assert pictures.get((), mkref('user', lambda id: 'jdoe@example.com'), cache1) == pic5078 return True79def testPages():80 # Get default page81 defpage = (("'entry", ("'title", 'app1'), ("'id", 'app1'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-01T00:00:00+00:00'), ("'content",)),)82 app1 = (("'entry", ("'title", 'app1'), ("'id", 'app1'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-03T00:00:00+00:00'), ("'content",)),)83 assert pages.get(('app1',), mkref('user', lambda id: 'jdoe@example.com'), mkcache('cache', {}), mkref('apps', lambda id: None)) == defpage84 defpagefromapp = (("'entry", ("'title", 'app1'), ("'id", 'app1'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-01T00:00:00+00:00'), ("'content",)),)85 assert pages.get(('app1',), mkref('user', lambda id: 'jdoe@example.com'), mkcache('cache', {}), mkref('apps', lambda id: app1)) == defpagefromapp86 # Get a page87 page1 = (("'entry", ("'title", 'app1'), ("'id", 'app1'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-02T00:00:00+00:00'), ("'content",)),)88 assert pages.get(('app1',), mkref('user', lambda id: 'jdoe@example.com'), mkcache('cache', {('apps', 'app1', 'htdocs', 'app.html') : page1}), mkref('apps', lambda id: app1)) == page189 # Put and get a page90 cache1 = mkcache('cache', {})91 page1updated = (("'entry", ("'title", 'app1'), ("'id", 'app1'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-01T00:00:00+00:00'), ("'content",)),)92 assert pages.put(('app1',), page1, mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', lambda id, app = None: app1 if app is None else True)) == True93 assert pages.get(('app1',), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', lambda id: app1)) == page1updated94 95 # Reject put from user other than the author96 app1otherauthor = (("'entry", ("'title", 'app1'), ("'id", 'app1'), ("'author", 'jane@example.com'), ("'updated", '2012-01-03T00:00:00+00:00'), ("'content",)),)97 page1otherauthor = (("'entry", ("'title", 'app1'), ("'id", 'app1'), ("'author", 'jane@example.com'), ("'updated", '2012-01-02T00:00:00+00:00')),)98 assert pages.put(('app1',), page1, mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', lambda id: app1otherauthor)) == False99 assert pages.put(('app1',), page1otherauthor, mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', lambda id: app1otherauthor)) == False100 assert pages.get(('app1',), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', lambda id: app1)) == page1updated101 # Reject delete from user other than the author102 assert pages.delete(('app1',), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', lambda id: app1otherauthor)) == False103 assert pages.get(('app1',), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', lambda id: app1)) == page1updated104 # Delete a page105 assert pages.delete(('app1',), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', lambda id, app = None: app1 if app is None else True)) == True106 assert pages.get(('app1',), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', lambda id: app1)) == defpagefromapp107 return True108def testIcons():109 if PIL is None:110 return True111 img16 = 'data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAOUlEQVQ4y2N0b3/7nwEH2FkpzGg7hQGn/OEcBkYmBgrBqAFUMIBiQDCeL3qY4ZTX33FqNB0Mj3QAAFC7Dhs7i7zzAAAAAElFTkSuQmCC'112 img50 = 'data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAACV0lEQVR4nO2YPU8UURSG3zMzO2wiIrguXwmthSEkJtBZmFgYG6n5Rf4VKmlILIw/YIstNgoVJhICy8zuyrIzy97vY6F8aH2LG3Of8hbnzZOZM5P70tsPI4ZHjKyr8ujwoN/7uD86+fK5tYXd9jb2WlvYpQSZjwwrUA17OBh0sX91jE8AkPgYHAJRJDSiSGhEkdCIIqERRUIjioRGFAmNKBIaUSQ0MiPryudAK+vaGSHYWQMA7GCcxsxKVESe7uwStdMQ7GBuz7Ly6PDAx/C7ECPF5LzXVXVZgMFqjPPqBzpsoUFIfWSwhqjP0NUTFLdn9Oz5m3c+ht+FOGtUXRayKvrqZjTMH2MlX8BaYwHL8PUqOxg1QaEm6OsaAwAgXxXNPzAzHBhMABFRQgB5DQCYmR0DDABZawu7XgMcjBzjQo1xpico2s18fbWZb7TnGutE5EXGOjalVBeXQp2NpL4EgKy9jT0fw29xCrPqFJ3r7zCmosFqM994uTj/anNxfieBnx0Rzs2+jacd6ypzJ+L7iViBylnoWYkTAVC7ma9vPnm083p58X1K5OU1nhpbWcf69Eac4M83N/O9I5QgowQp6PdOEEAJUZoSZb5EUqIsIUof7t1/80OMIqERRUIjioRGFAmNKBIaUSQ0okhoRJHQyKyA54Lu7/LMMhvp3GxqbOXrhnhjbS2dE5b5vqAb9uC1oHtYnjHApVDnX8fTjmHWCchL+SCdE8fX0+5I6fuCbukFvBZ0D8szU2P4dK6x0p5rrLXyhreCzjLMT6WLgVT9K2UGPmZGfPMLWsI5A943r6EAAAAASUVORK5CYII='113 # Get default icon114 deficon = (("'entry", ("'title", 'app1'), ("'id", 'app1'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-01T00:00:00+00:00'), ("'content",)),)115 app1 = (("'entry", ("'title", 'app1'), ("'id", 'app1'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-03T00:00:00+00:00'), ()),)116 assert icons.get(('app1',), mkref('user', lambda id: 'jdoe@example.com'), mkcache('cache', {}), mkref('apps', lambda id: None)) == deficon117 deficonfromapp = (("'entry", ("'title", 'app1'), ("'id", 'app1'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-01T00:00:00+00:00'), ("'content",)),)118 assert icons.get(('app1',), mkref('user', lambda id: 'jdoe@example.com'), mkcache('cache', {}), mkref('apps', lambda id: app1)) == deficonfromapp119 # Get a icon120 icon1 = (("'entry", ("'title", 'app1'), ("'id", 'app1'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-02T00:00:00+00:00'), ("'content", ("'icon", ("'image", img16)))),)121 assert icons.get(('app1',), mkref('user', lambda id: 'jdoe@example.com'), mkcache('cache', {('apps', 'app1', 'app.icon') : icon1}), mkref('apps', lambda id: app1)) == icon1122 # Put and get a icon123 cache1 = mkcache('cache', {})124 icon1updated = (("'entry", ("'title", 'app1'), ("'id", 'app1'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-01T00:00:00+00:00'), ("'content", ("'icon", ("'image", img50)))),)125 assert icons.put(('app1',), icon1, mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', lambda id, app = None: app1 if app is None else True)) == True126 assert icons.get(('app1',), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', lambda id: app1)) == icon1updated127 128 # Reject put from user other than the author129 app1otherauthor = (("'entry", ("'title", 'app1'), ("'id", 'app1'), ("'author", 'jane@example.com'), ("'updated", '2012-01-03T00:00:00+00:00'), ("'content",)),)130 icon1otherauthor = (("'entry", ("'title", 'app1'), ("'id", 'app1'), ("'author", 'jane@example.com'), ("'updated", '2012-01-02T00:00:00+00:00')),)131 assert icons.put(('app1',), icon1, mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', lambda id: app1otherauthor)) == False132 assert icons.put(('app1',), icon1otherauthor, mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', lambda id: app1otherauthor)) == False133 assert icons.get(('app1',), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', lambda id: app1)) == icon1updated134 # Reject delete from user other than the author135 assert icons.delete(('app1',), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', lambda id: app1otherauthor)) == False136 assert icons.get(('app1',), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', lambda id: app1)) == icon1updated137 # Put an upload token in an icon 138 icon1token = (("'entry", ("'title", 'app1'), ("'id", 'app1'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-01T00:00:00+00:00'), ("'content", ("'icon", ("'token", '1234')))),)139 assert icons.put(('app1',), icon1token, mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', lambda id: app1)) == True140 assert icons.get(('app1',), mkref('user', lambda id: 'another@example.com'), cache1, mkref('apps', lambda id: app1)) == icon1updated141 icon1updatedwithtoken = (("'entry", ("'title", 'app1'), ("'id", 'app1'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-01T00:00:00+00:00'), ("'content", ("'icon", ("'image", img50), ("'token", '1234')))),)142 assert icons.get(('app1',), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', lambda id: app1)) == icon1updatedwithtoken143 # Reject upload with invalid token144 icon1badtoken = (("'entry", ("'title", 'app1'), ("'id", 'app1'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-01T00:00:00+00:00'), ("'content", ("'icon", ("'image", img50), ("'token", '4567')))),)145 assert icons.put(('app1',), icon1badtoken, mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', lambda id: app1)) == False146 # Upload with valid token147 icon1oktoken = (("'entry", ("'title", 'app1'), ("'id", 'app1'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-01T00:00:00+00:00'), ("'content", ("'icon", ("'image", img50), ("'token", '1234')))),)148 assert icons.put(('app1',), icon1oktoken, mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', lambda id, app = None: app1 if app is None else True)) == True149 assert icons.get(('app1',), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', lambda id: app1)) == icon1updated150 # Delete a icon151 assert icons.delete(('app1',), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', lambda id, app = None: app1 if app is None else True)) == True152 assert icons.get(('app1',), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', lambda id: app1)) == deficonfromapp153 return True154def testComposites():155 # Get default composite156 defcomposite = (("'entry", ("'title", 'app1'), ("'id", 'app1'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-01T00:00:00+00:00'), ("'content",)),)157 app1 = (("'entry", ("'title", 'app1'), ("'id", 'app1'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-03T00:00:00+00:00'), ("'content",)),)158 assert composites.get(('app1',), mkref('user', lambda id: 'jdoe@example.com'), mkcache('cache', {}), mkref('apps', lambda id: None)) == defcomposite159 defcompositefromapp = (("'entry", ("'title", 'app1'), ("'id", 'app1'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-01T00:00:00+00:00'), ("'content",)),)160 assert composites.get(('app1',), mkref('user', lambda id: 'jdoe@example.com'), mkcache('cache', {}), mkref('apps', lambda id: app1)) == defcompositefromapp161 # Get a composite162 composite1 = (("'entry", ("'title", 'app1'), ("'id", 'app1'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-02T00:00:00+00:00'), ("'content",)),)163 assert composites.get(('app1',), mkref('user', lambda id: 'jdoe@example.com'), mkcache('cache', {('apps', 'app1', 'app.composite') : composite1}), mkref('apps', lambda id: app1)) == composite1164 # Put and get a composite165 cache1 = mkcache('cache', {})166 composite1updated = (("'entry", ("'title", 'app1'), ("'id", 'app1'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-01T00:00:00+00:00'), ("'content",)),)167 assert composites.put(('app1',), composite1, mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', lambda id, app = None: app1 if app is None else True)) == True168 assert composites.get(('app1',), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', lambda id: app1)) == composite1updated169 170 # Reject put from user other than the author171 app1otherauthor = (("'entry", ("'title", 'app1'), ("'id", 'app1'), ("'author", 'jane@example.com'), ("'updated", '2012-01-03T00:00:00+00:00'), ("'content",)),)172 composite1otherauthor = (("'entry", ("'title", 'app1'), ("'id", 'app1'), ("'author", 'jane@example.com'), ("'updated", '2012-01-02T00:00:00+00:00')),)173 assert composites.put(('app1',), composite1, mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', lambda id: app1otherauthor)) == False174 assert composites.put(('app1',), composite1otherauthor, mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', lambda id: app1otherauthor)) == False175 assert composites.get(('app1',), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', lambda id: app1)) == composite1updated176 # Reject delete from user other than the author177 assert composites.delete(('app1',), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', lambda id: app1otherauthor)) == False178 assert composites.get(('app1',), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', lambda id: app1)) == composite1updated179 # Delete a composite180 assert composites.delete(('app1',), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', lambda id, app = None: app1 if app is None else True)) == True181 assert composites.get(('app1',), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', lambda id: app1)) == defcompositefromapp182 return True183def testApps():184 # Get default app185 assert apps.get(('app1',), mkref('user', lambda id: 'jdoe@example.com'), mkcache('cache', {}), mkref('db', lambda id: None), mkref('dashboard', lambda id: None), mkref('store', lambda id: None), mkref('composites', lambda id: None), mkref('pages', lambda id: None), mkref('icons', lambda id: None)) is None186 # Get an app187 app1 = (("'entry", ("'title", 'app1'), ("'id", 'app1'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-01T00:00:00+00:00'), ("'content", ("'info", ("'description", '')))),)188 assert apps.get(('app1',), mkref('user', lambda id: 'jdoe@example.com'), mkcache('cache', {('apps', 'app1', 'app.info') : app1}), mkref('db', lambda id: None), mkref('dashboard', lambda id: None), mkref('store', lambda id: None), mkref('composites', lambda id: None), mkref('pages', lambda id: None), mkref('icons', lambda id: None)) == app1189 # Put and get an app190 cache1 = mkcache('cache', {})191 assert apps.put(('app1',), app1, mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('db', lambda id: None), mkref('dashboard', lambda id, app: True), mkref('store', lambda id, app: True), mkref('composites', lambda id, app: True), mkref('pages', lambda id, app: True), mkref('icons', lambda id, app: True)) == True192 assert apps.get(('app1',), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('db', lambda id: None), mkref('dashboard', lambda id: None), mkref('store', lambda id: None), mkref('composites', lambda id: None), mkref('pages', lambda id: None), mkref('icons', lambda id: None)) == app1193 return True194 195 # Reject put from user other than the author196 app1otherauthor = (("'entry", ("'title", 'app1'), ("'id", 'app1'), ("'author", 'jane@example.com'), ("'updated", '2012-01-03T00:00:00+00:00'), ("'content",)),)197 assert apps.put(('app1',), app1, mkref('user', lambda id: 'jane@example.com'), cache1, mkref('db', lambda id: None), mkref('dashboard', lambda id, app: True), mkref('store', lambda id, app: True), mkref('composites', lambda id, app: True), mkref('pages', lambda id, app: True), mkref('icons', lambda id, app: True)) == false198 assert apps.get(('app1',), mkref('user', lambda id: 'jane@example.com'), cache1, mkref('db', lambda id: None), mkref('dashboard', lambda id: None), mkref('store', lambda id: None), mkref('composites', lambda id: None), mkref('pages', lambda id: None), mkref('icons', lambda id: None)) == app1199 # Reject delete from user other than the author200 assert apps.delete(('app1',), mkref('user', lambda id: 'jane@example.com'), cache1, mkref('db', lambda id: None), mkref('dashboard', lambda id: None), mkref('store', lambda id: None), mkref('composites', lambda id: None), mkref('pages', lambda id: None), mkref('icons', lambda id: None)) == False201 assert apps.get(('app1',), mkref('user', lambda id: 'jane@example.com'), cache1, mkref('db', lambda id: None), mkref('dashboard', lambda id: None), mkref('store', lambda id: None), mkref('composites', lambda id: None), mkref('pages', lambda id: None), mkref('icons', lambda id: None)) == app1202 # Delete an app203 assert apps.delete(('app1',), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('db', lambda id: None), mkref('dashboard', lambda id: None), mkref('store', lambda id: None), mkref('composites', lambda id: None), mkref('pages', lambda id: None), mkref('icons', lambda id: None)) == True204 assert apps.get(('app1',), mkref('user', lambda id: 'jdoe@example.com'), mkcache('cache', {}), mkref('db', lambda id: None), mkref('dashboard', lambda id: None), mkref('store', lambda id: None), mkref('composites', lambda id: None), mkref('pages', lambda id: None), mkref('icons', lambda id: None)) is None205 return True206def testStore():207 getapp = lambda id: (("'entry", ("'title", car(id)), ("'id", car(id)), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-02T00:00:00+00:00'), ("'content", ("'info", ("'description", car(id))))),)208 # Get default store209 defstore = (("'feed", ("'title", 'App Store'), ("'id", 'featured')),)210 assert store.get(('featured',), mkref('user', lambda id: 'jdoe@example.com'), mkcache('cache', {}), mkref('apps', getapp), mkref('ratings', lambda id: None)) == defstore211 # Get a store212 store1= (("'feed", ("'title", 'App Store'), ("'id", 'featured'), ("'entry", ("'title", 'app1'), ("'id", 'app1'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-02T00:00:00+00:00'), ("'content", ("'info", ("'description", 'app1')))), ("'entry", ("'title", 'app2'), ("'id", 'app2'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-02T00:00:00+00:00'), ("'content", ("'info", ("'description", 'app2'))))),)213 assert store.get(('featured',), mkref('user', lambda id: 'jdoe@example.com'), mkcache('cache', {('store', 'featured', 'store.apps') : store1}), mkref('apps', getapp), mkref('ratings', lambda id: None)) == store1214 215 store1compact = (("'feed", ("'title", 'App Store'), ("'id", 'featured'), ("'entry", ((("'title", 'app1'), ("'id", 'app1'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-02T00:00:00+00:00'), ("'content", ("'info", ("'description", 'app1')))), (("'title", 'app2'), ("'id", 'app2'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-02T00:00:00+00:00'), ("'content", ("'info", ("'description", 'app2'))))))),)216 assert store.get(('featured',), mkref('user', lambda id: 'jdoe@example.com'), mkcache('cache', {('store', 'featured', 'store.apps') : store1compact}), mkref('apps', getapp), mkref('ratings', lambda id: None)) == store1217 # Put an app in an empty store218 cache1 = mkcache('cache', {})219 app1 = (("'entry", ("'title", 'app1'), ("'id", 'app1'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-02T00:00:00+00:00'), ("'content", ("'info", ("'description", 'app1')))),)220 store1withapp1 = (("'feed", ("'title", 'App Store'), ("'id", 'featured'), ("'entry", ("'title", 'app1'), ("'id", 'app1'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-02T00:00:00+00:00'), ("'content", ("'info", ("'description", 'app1'))))),)221 assert store.put(('featured', 'app1'), app1, mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', getapp), mkref('ratings', lambda id: None)) == True222 assert store.get(('featured',), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', getapp), mkref('ratings', lambda id: None)) == store1withapp1223 assert store.put(('featured', 'app1'), app1, mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', getapp), mkref('ratings', lambda id: None)) == True224 assert store.get(('featured',), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', getapp), mkref('ratings', lambda id: None)) == store1withapp1225 # Put a second app in the store226 app2 = (("'entry", ("'title", 'app2'), ("'id", 'app2'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-02T00:00:00+00:00'), ("'content", ("'info", ("'description", 'app2')))),)227 store1withapp2 = (("'feed", ("'title", 'App Store'), ("'id", 'featured'), ("'entry", ("'title", 'app1'), ("'id", 'app1'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-02T00:00:00+00:00'), ("'content", ("'info", ("'description", 'app1')))), ("'entry", ("'title", 'app2'), ("'id", 'app2'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-02T00:00:00+00:00'), ("'content", ("'info", ("'description", 'app2'))))),)228 assert store.put(('featured', 'app2'), app2, mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', getapp), mkref('ratings', lambda id: None)) == True229 assert store.get(('featured',), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', getapp), mkref('ratings', lambda id: None)) == store1withapp2230 assert store.put(('featured', 'app1'), app1, mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', getapp), mkref('ratings', lambda id: None)) == True231 assert store.get(('featured',), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', getapp), mkref('ratings', lambda id: None)) == store1withapp2232 assert store.put(('featured', 'app2'), app2, mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', getapp), mkref('ratings', lambda id: None)) == True233 assert store.get(('featured',), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', getapp), mkref('ratings', lambda id: None)) == store1withapp2234 # Put a third app in the store235 app3 = (("'entry", ("'title", 'app3'), ("'id", 'app3'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-02T00:00:00+00:00'), ("'content", ("'info", ("'description", 'app3')))),)236 store1withapp3 = (("'feed", ("'title", 'App Store'), ("'id", 'featured'), ("'entry", ("'title", 'app1'), ("'id", 'app1'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-02T00:00:00+00:00'), ("'content", ("'info", ("'description", 'app1')))), ("'entry", ("'title", 'app2'), ("'id", 'app2'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-02T00:00:00+00:00'), ("'content", ("'info", ("'description", 'app2')))), ("'entry", ("'title", 'app3'), ("'id", 'app3'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-02T00:00:00+00:00'), ("'content", ("'info", ("'description", 'app3'))))),)237 assert store.put(('featured', 'app3'), app3, mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', getapp), mkref('ratings', lambda id: None)) == True238 assert store.get(('featured',), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', getapp), mkref('ratings', lambda id: None)) == store1withapp3239 assert store.put(('featured', 'app1'), app1, mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', getapp), mkref('ratings', lambda id: None)) == True240 assert store.get(('featured',), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', getapp), mkref('ratings', lambda id: None)) == store1withapp3241 assert store.put(('featured', 'app2'), app2, mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', getapp), mkref('ratings', lambda id: None)) == True242 assert store.get(('featured',), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', getapp), mkref('ratings', lambda id: None)) == store1withapp3243 assert store.put(('featured', 'app3'), app3, mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', getapp), mkref('ratings', lambda id: None)) == True244 assert store.get(('featured',), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', getapp), mkref('ratings', lambda id: None)) == store1withapp3245 # Get an app from the store246 assert store.get(('featured','app1'), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', getapp), mkref('ratings', lambda id: None)) == app1247 assert store.get(('featured','app2'), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', getapp), mkref('ratings', lambda id: None)) == app2248 assert store.get(('featured','app3'), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', getapp), mkref('ratings', lambda id: None)) == app3249 # Put a third app in the store, starting from a compacted list250 cache2 = mkcache('cache', {('store', 'featured', 'store.apps') : store1compact})251 assert store.put(('featured', 'app3'), app3, mkref('user', lambda id: 'jdoe@example.com'), cache2, mkref('apps', getapp), mkref('ratings', lambda id: None)) == True252 assert store.get(('featured',), mkref('user', lambda id: 'jdoe@example.com'), cache2, mkref('apps', getapp), mkref('ratings', lambda id: None)) == store1withapp3253 # Delete the apps254 assert store.delete(('featured', 'app2'), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', getapp), mkref('ratings', lambda id: None)) == True255 assert store.delete(('featured', 'app4'), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', getapp), mkref('ratings', lambda id: None)) == False256 assert store.delete(('featured', 'app1'), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', getapp), mkref('ratings', lambda id: None)) == True257 assert store.delete(('featured', 'app3'), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', getapp), mkref('ratings', lambda id: None)) == True258 assert store.get(('featured',), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', getapp), mkref('ratings', lambda id: None)) == defstore259 # Delete a store260 assert store.delete(('featured',), mkref('user', lambda id: 'jdoe@example.com'), cache2, mkref('apps', getapp), mkref('ratings', lambda id: None)) == True261 assert store.get(('featured',), mkref('user', lambda id: 'jdoe@example.com'), cache2, mkref('apps', getapp), mkref('ratings', lambda id: None)) == defstore262 return True263def testDashboards():264 getapp = lambda id: (("'entry", ("'title", car(id)), ("'id", car(id)), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-01T00:00:00+00:00'), ("'content", ("'info", ("'description", car(id))))),)265 # Get default dashboard266 defdashboard = (("'feed", ("'title", 'Your Apps'), ("'id", 'jdoe@example.com')),)267 assert dashboards.get((), mkref('user', lambda id: 'jdoe@example.com'), mkcache('cache', {}), mkref('apps', getapp), mkref('ratings', lambda id: None)) == defdashboard268 # Get the user's dashboard269 dash1= (("'feed", ("'title", 'Your Apps'), ("'id", 'jdoe@example.com'), ("'entry", ("'title", 'app1'), ("'id", 'app1'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-01T00:00:00+00:00'), ("'content", ("'info", ("'description", 'app1')))), ("'entry", ("'title", 'app2'), ("'id", 'app2'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-01T00:00:00+00:00'), ("'content", ("'info", ("'description", 'app2'))))),)270 assert dashboards.get((), mkref('user', lambda id: 'jdoe@example.com'), mkcache('cache', {('dashboards', 'jdoe@example.com', 'user.apps') : dash1}), mkref('apps', getapp), mkref('ratings', lambda id: None)) == dash1271 272 dash1compact = (("'feed", ("'title", 'Your Apps'), ("'id", 'jdoe@example.com'), ("'entry", ((("'title", 'app1'), ("'id", 'app1'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-01T00:00:00+00:00'), ("'content", ("'info", ("'description", 'app1')))), (("'title", 'app2'), ("'id", 'app2'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-01T00:00:00+00:00'), ("'content", ("'info", ("'description", 'app2'))))))),)273 assert dashboards.get((), mkref('user', lambda id: 'jdoe@example.com'), mkcache('cache', {('dashboards', 'jdoe@example.com', 'user.apps') : dash1compact}), mkref('apps', getapp), mkref('ratings', lambda id: None)) == dash1274 # Put an app in an empty dashboard275 cache1 = mkcache('cache', {})276 app1 = (("'entry", ("'title", 'app1'), ("'id", 'app1'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-01T00:00:00+00:00'), ("'content", ("'info", ("'description", 'app1')))),)277 dash1withapp1 = (("'feed", ("'title", 'Your Apps'), ("'id", 'jdoe@example.com'), ("'entry", ("'title", 'app1'), ("'id", 'app1'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-01T00:00:00+00:00'), ("'content", ("'info", ("'description", 'app1'))))),)278 assert dashboards.put(('app1',), app1, mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', getapp), mkref('ratings', lambda id: None)) == True279 assert dashboards.get((), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', getapp), mkref('ratings', lambda id: None)) == dash1withapp1280 assert dashboards.put(('app1',), app1, mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', getapp), mkref('ratings', lambda id: None)) == True281 assert dashboards.get((), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', getapp), mkref('ratings', lambda id: None)) == dash1withapp1282 # Put a second app in the dashboard283 app2 = (("'entry", ("'title", 'app2'), ("'id", 'app2'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-01T00:00:00+00:00'), ("'content", ("'info", ("'description", 'app2')))),)284 dash1withapp2 = (("'feed", ("'title", 'Your Apps'), ("'id", 'jdoe@example.com'), ("'entry", ("'title", 'app1'), ("'id", 'app1'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-01T00:00:00+00:00'), ("'content", ("'info", ("'description", 'app1')))), ("'entry", ("'title", 'app2'), ("'id", 'app2'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-01T00:00:00+00:00'), ("'content", ("'info", ("'description", 'app2'))))),)285 assert dashboards.put(('app2',), app2, mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', getapp), mkref('ratings', lambda id: None)) == True286 assert dashboards.get((), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', getapp), mkref('ratings', lambda id: None)) == dash1withapp2287 assert dashboards.put(('app1',), app1, mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', getapp), mkref('ratings', lambda id: None)) == True288 assert dashboards.get((), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', getapp), mkref('ratings', lambda id: None)) == dash1withapp2289 assert dashboards.put(('app2',), app2, mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', getapp), mkref('ratings', lambda id: None)) == True290 assert dashboards.get((), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', getapp), mkref('ratings', lambda id: None)) == dash1withapp2291 # Put a third app in the dashboard292 app3 = (("'entry", ("'title", 'app3'), ("'id", 'app3'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-01T00:00:00+00:00'), ("'content", ("'info", ("'description", 'app3')))),)293 dash1withapp3 = (("'feed", ("'title", 'Your Apps'), ("'id", 'jdoe@example.com'), ("'entry", ("'title", 'app1'), ("'id", 'app1'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-01T00:00:00+00:00'), ("'content", ("'info", ("'description", 'app1')))), ("'entry", ("'title", 'app2'), ("'id", 'app2'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-01T00:00:00+00:00'), ("'content", ("'info", ("'description", 'app2')))), ("'entry", ("'title", 'app3'), ("'id", 'app3'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-01T00:00:00+00:00'), ("'content", ("'info", ("'description", 'app3'))))),)294 assert dashboards.put(('app3',), app3, mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', getapp), mkref('ratings', lambda id: None)) == True295 assert dashboards.get((), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', getapp), mkref('ratings', lambda id: None)) == dash1withapp3296 assert dashboards.put(('app1',), app1, mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', getapp), mkref('ratings', lambda id: None)) == True297 assert dashboards.get((), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', getapp), mkref('ratings', lambda id: None)) == dash1withapp3298 assert dashboards.put(('app2',), app2, mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', getapp), mkref('ratings', lambda id: None)) == True299 assert dashboards.get((), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', getapp), mkref('ratings', lambda id: None)) == dash1withapp3300 assert dashboards.put(('app3',), app3, mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', getapp), mkref('ratings', lambda id: None)) == True301 assert dashboards.get((), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', getapp), mkref('ratings', lambda id: None)) == dash1withapp3302 # Get an app from the user's dashboard303 assert dashboards.get(('app1',), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', getapp), mkref('ratings', lambda id: None)) == app1304 assert dashboards.get(('app2',), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', getapp), mkref('ratings', lambda id: None)) == app2305 assert dashboards.get(('app3',), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', getapp), mkref('ratings', lambda id: None)) == app3306 # Put a third app in the dashboard, starting from a compacted list307 cache2 = mkcache('cache', {('dashboards', 'jdoe@example.com', 'user.apps') : dash1compact})308 assert dashboards.put(('app3',), app3, mkref('user', lambda id: 'jdoe@example.com'), cache2, mkref('apps', getapp), mkref('ratings', lambda id: None)) == True309 assert dashboards.get((), mkref('user', lambda id: 'jdoe@example.com'), cache2, mkref('apps', getapp), mkref('ratings', lambda id: None)) == dash1withapp3310 # Delete the apps311 assert dashboards.delete(('app2',), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', getapp), mkref('ratings', lambda id: None)) == True312 assert dashboards.delete(('app4',), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', getapp), mkref('ratings', lambda id: None)) == False313 assert dashboards.delete(('app1',), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', getapp), mkref('ratings', lambda id: None)) == True314 assert dashboards.delete(('app3',), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', getapp), mkref('ratings', lambda id: None)) == True315 assert dashboards.get((), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', getapp), mkref('ratings', lambda id: None)) == defdashboard316 # Delete the dashboard317 assert dashboards.delete((), mkref('user', lambda id: 'jdoe@example.com'), cache2, mkref('apps', getapp), mkref('ratings', lambda id: None)) == True318 assert dashboards.get((), mkref('user', lambda id: 'jdoe@example.com'), cache2, mkref('apps', getapp), mkref('ratings', lambda id: None)) == defdashboard319 return True320def testReviews():321 app1 = (("'entry", ("'title", 'app1'), ("'id", 'app1'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-01T00:00:00+00:00'), ("'content", ("'info", ("'description", '')))),)322 # Get default reviews323 defreviews = (("'feed", ("'title", 'Your Reviews'), ("'id", 'jdoe@example.com')),)324 assert reviews.get((), mkref('user', lambda id: 'jdoe@example.com'), mkcache('cache', {}), mkref('apps', lambda id: app1), mkref('ratings', lambda id, patch: True)) == defreviews325 # Get the user's reviews326 reviews1= (("'feed", ("'title", 'Your Reviews'), ("'id", 'jdoe@example.com'), ("'entry", ("'title", 'app1'), ("'id", 'app1'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-01T00:00:00+00:00'), ("'content", ("'rating", '1'))), ("'entry", ("'title", 'app2'), ("'id", 'app2'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-01T00:00:00+00:00'), ("'content", ("'rating", '2')))),)327 assert reviews.get((), mkref('user', lambda id: 'jdoe@example.com'), mkcache('cache', {('reviews', 'jdoe@example.com', 'user.reviews') : reviews1}), mkref('apps', lambda id: app1), mkref('ratings', lambda id, patch: True)) == reviews1328 329 reviews1compact = (("'feed", ("'title", 'Your Reviews'), ("'id", 'jdoe@example.com'), ("'entry", ((("'title", 'app1'), ("'id", 'app1'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-01T00:00:00+00:00'), ("'content", ("'rating", '1'))), (("'title", 'app2'), ("'id", 'app2'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-01T00:00:00+00:00'), ("'content", ("'rating", '2')))))),)330 assert reviews.get((), mkref('user', lambda id: 'jdoe@example.com'), mkcache('cache', {('reviews', 'jdoe@example.com', 'user.reviews') : reviews1compact}), mkref('apps', lambda id: app1), mkref('ratings', lambda id, patch: True)) == reviews1331 # Put a review in an empty reviews record332 cache1 = mkcache('cache', {})333 app1review = (("'entry", ("'title", 'app1'), ("'id", 'app1'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-01T00:00:00+00:00'), ("'content", ("'rating", '1'))),)334 reviews1withapp1 = (("'feed", ("'title", 'Your Reviews'), ("'id", 'jdoe@example.com'), ("'entry", ("'title", 'app1'), ("'id", 'app1'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-01T00:00:00+00:00'), ("'content", ("'rating", '1')))),)335 assert reviews.put(('app1',), app1review, mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', lambda id: app1), mkref('ratings', lambda id, patch: True)) == True336 assert reviews.get((), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', lambda id: app1), mkref('ratings', lambda id, patch: True)) == reviews1withapp1337 assert reviews.put(('app1',), app1review, mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', lambda id: app1), mkref('ratings', lambda id, patch: True)) == True338 assert reviews.get((), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', lambda id: app1), mkref('ratings', lambda id, patch: True)) == reviews1withapp1339 # Put a second review in the reviews record340 app2review = (("'entry", ("'title", 'app2'), ("'id", 'app2'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-01T00:00:00+00:00'), ("'content", ("'rating", '2'))),)341 reviews1withapp2 = (("'feed", ("'title", 'Your Reviews'), ("'id", 'jdoe@example.com'), ("'entry", ("'title", 'app1'), ("'id", 'app1'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-01T00:00:00+00:00'), ("'content", ("'rating", '1'))), ("'entry", ("'title", 'app2'), ("'id", 'app2'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-01T00:00:00+00:00'), ("'content", ("'rating", '2')))),)342 assert reviews.put(('app2',), app2review, mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', lambda id: app1), mkref('ratings', lambda id, patch: True)) == True343 assert reviews.get((), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', lambda id: app1), mkref('ratings', lambda id, patch: True)) == reviews1withapp2344 assert reviews.put(('app1',), app1review, mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', lambda id: app1), mkref('ratings', lambda id, patch: True)) == True345 assert reviews.get((), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', lambda id: app1), mkref('ratings', lambda id, patch: True)) == reviews1withapp2346 assert reviews.put(('app2',), app2review, mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', lambda id: app1), mkref('ratings', lambda id, patch: True)) == True347 assert reviews.get((), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', lambda id: app1), mkref('ratings', lambda id, patch: True)) == reviews1withapp2348 # Put a third review in the reviews record349 app3review = (("'entry", ("'title", 'app3'), ("'id", 'app3'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-01T00:00:00+00:00'), ("'content", ("'rating", '3'))),)350 reviews1withapp3 = (("'feed", ("'title", 'Your Reviews'), ("'id", 'jdoe@example.com'), ("'entry", ("'title", 'app1'), ("'id", 'app1'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-01T00:00:00+00:00'), ("'content", ("'rating", '1'))), ("'entry", ("'title", 'app2'), ("'id", 'app2'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-01T00:00:00+00:00'), ("'content", ("'rating", '2'))), ("'entry", ("'title", 'app3'), ("'id", 'app3'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-01T00:00:00+00:00'), ("'content", ("'rating", '3')))),)351 assert reviews.put(('app3',), app3review, mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', lambda id: app1), mkref('ratings', lambda id, patch: True)) == True352 assert reviews.get((), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', lambda id: app1), mkref('ratings', lambda id, patch: True)) == reviews1withapp3353 assert reviews.put(('app1',), app1review, mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', lambda id: app1), mkref('ratings', lambda id, patch: True)) == True354 assert reviews.get((), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', lambda id: app1), mkref('ratings', lambda id, patch: True)) == reviews1withapp3355 assert reviews.put(('app2',), app2review, mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', lambda id: app1), mkref('ratings', lambda id, patch: True)) == True356 assert reviews.get((), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', lambda id: app1), mkref('ratings', lambda id, patch: True)) == reviews1withapp3357 assert reviews.put(('app3',), app3review, mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', lambda id: app1), mkref('ratings', lambda id, patch: True)) == True358 assert reviews.get((), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', lambda id: app1), mkref('ratings', lambda id, patch: True)) == reviews1withapp3359 # Get a review from the user's reviews360 assert reviews.get(('app1',), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', lambda id: app1), mkref('ratings', lambda id, patch: True)) == app1review361 assert reviews.get(('app2',), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', lambda id: app1), mkref('ratings', lambda id, patch: True)) == app2review362 assert reviews.get(('app3',), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', lambda id: app1), mkref('ratings', lambda id, patch: True)) == app3review363 # Put a third review in the user's reviews record, starting from a compacted list364 cache2 = mkcache('cache', {('reviews', 'jdoe@example.com', 'user.reviews') : reviews1compact})365 assert reviews.put(('app3',), app3review, mkref('user', lambda id: 'jdoe@example.com'), cache2, mkref('apps', lambda id: app1), mkref('ratings', lambda id, patch: True)) == True366 assert reviews.get((), mkref('user', lambda id: 'jdoe@example.com'), cache2, mkref('apps', lambda id: app1), mkref('ratings', lambda id, patch: True)) == reviews1withapp3367 # Delete the reviews368 assert reviews.delete(('app2',), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', lambda id: app1), mkref('ratings', lambda id, patch: True)) == True369 assert reviews.delete(('app4',), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', lambda id: app1), mkref('ratings', lambda id, patch: True)) == False370 assert reviews.delete(('app1',), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', lambda id: app1), mkref('ratings', lambda id, patch: True)) == True371 assert reviews.delete(('app3',), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', lambda id: app1), mkref('ratings', lambda id, patch: True)) == True372 assert reviews.get((), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('apps', lambda id: app1), mkref('ratings', lambda id, patch: True)) == defreviews373 # Delete the reviews record374 assert reviews.delete((), mkref('user', lambda id: 'jdoe@example.com'), cache2, mkref('apps', lambda id: app1), mkref('ratings', lambda id, patch: True)) == True375 assert reviews.get((), mkref('user', lambda id: 'jdoe@example.com'), cache2, mkref('apps', lambda id: app1), mkref('ratings', lambda id, patch: True)) == defreviews376 return True377def testRatings():378 # Get default ratings379 defratings = (("'entry", ("'title", 'app1'), ("'id", 'app1'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-01T00:00:00+00:00'), ("'content",)),)380 app1 = (("'entry", ("'title", 'app1'), ("'id", 'app1'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-03T00:00:00+00:00'), ("'content",)),)381 assert ratings.get(('app1',), mkref('user', lambda id: 'jdoe@example.com'), mkcache('cache', {}), mkref('db', lambda id: None), mkref('apps', lambda id: None)) == defratings382 defratingsfromapp = (("'entry", ("'title", 'app1'), ("'id", 'app1'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-01T00:00:00+00:00'), ("'content",)),)383 assert ratings.get(('app1',), mkref('user', lambda id: 'jdoe@example.com'), mkcache('cache', {}), mkref('db', lambda id: None), mkref('apps', lambda id: app1)) == defratingsfromapp384 # Get an app ratings385 ratings1 = (("'entry", ("'title", 'app1'), ("'id", 'app1'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-02T00:00:00+00:00'), ("'content",)),)386 assert ratings.get(('app1',), mkref('user', lambda id: 'jdoe@example.com'), mkcache('cache', {('ratings', 'app1', 'app.ratings') : ratings1}), mkref('db', lambda id: None), mkref('apps', lambda id: app1)) == ratings1387 # Put and get an app ratings388 cache1 = mkcache('cache', {})389 ratings1updated = (("'entry", ("'title", 'app1'), ("'id", 'app1'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-01T00:00:00+00:00'), ("'content",)),)390 assert ratings.put(('app1',), ratings1, mkref('user', lambda id: 'admin'), cache1, mkref('db', lambda id: None), mkref('apps', lambda id: app1)) == True391 assert ratings.get(('app1',), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('db', lambda id: None), mkref('apps', lambda id: app1)) == ratings1updated392 393 # Reject put from user other than admin394 ratings1otheruser = (("'entry", ("'title", 'app1'), ("'id", 'app1'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-04T00:00:00+00:00'), ("'content",)),)395 assert ratings.put(('app1',), ratings1otheruser, mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('db', lambda id: None), mkref('apps', lambda id: app1)) == False396 assert ratings.get(('app1',), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('db', lambda id: None), mkref('apps', lambda id: app1)) == ratings1updated397 # Patch an app ratings398 app2 = (("'entry", ("'title", 'app2'), ("'id", 'app2'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-03T00:00:00+00:00'), ("'content",)),)399 ratings2patch = (("'entry", ("'title", 'app2'), ("'id", 'app2'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-01T00:00:00+00:00'), ("'content", ("'patch", ("'old", '3'), ("'new", '4')))),)400 assert ratings.patch(('app2',), ratings2patch, mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('db', lambda id: None), mkref('apps', lambda id: app2)) == True401 ratings2patched = cache1.get(("ratings", 'app2', "app.ratings"))402 assert(cadr(content(ratings2patched)).find('(define orating 3)') != -1)403 assert(cadr(content(ratings2patched)).find('(define nrating 4)') != -1)404 # Reject delete from user other than admin405 assert ratings.delete(('app1',), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('db', lambda id: None), mkref('apps', lambda id: app1)) == False406 assert ratings.get(('app1',), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('db', lambda id: None), mkref('apps', lambda id: app1)) == ratings1updated407 # Delete an app ratings408 assert ratings.delete(('app1',), mkref('user', lambda id: 'admin'), cache1, mkref('db', lambda id: None), mkref('apps', lambda id: app1)) == True409 assert ratings.get(('app1',), mkref('user', lambda id: 'jdoe@example.com'), cache1, mkref('db', lambda id: None), mkref('apps', lambda id: app1)) == defratingsfromapp410 return True411def testSelector():412 assert selector.get(('apps', 'abc', 'app.info'), (1, 2)) == (1,)413 assert selector.get(('apps', 'nbc', 'app.info'), (1, 2)) == (2,)414 assert selector.get(('apps', 'nbc', 'app.info', ("'xyz", 'utv')), (1, 2)) == (2,)415 assert selector.get(('apps', 'nbc', 'app.info', ("'limit", '10')), (1, 2)) == (1, 2)416 return True417def testSearch():418 assert search.get((("'q", 'abc def'),), mkref('user', lambda id: 'jdoe@example.com'), mkcache('cache', {}), mkref('db', lambda id: ((("'entry", ("'title", 'app1'), ("'id", 'app1'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-02T00:00:00+00:00'), ("'content", ("'info", ("'description", 'app1')))),), (("'entry", ("'title", 'app2'), ("'id", 'app2'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-02T00:00:00+00:00'), ("'content", ("'info", ("'description", 'app2')))),))), mkref('apps', lambda id: None), mkref('ratings', lambda id: None)) == (("'feed", ("'title", 'Search Results'), ("'id", 'search'), ("'entry", ("'title", 'app1'), ("'id", 'app1'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-02T00:00:00+00:00'), ("'content", ("'info", ("'description", 'app1')))), ("'entry", ("'title", 'app2'), ("'id", 'app2'), ("'author", 'jdoe@example.com'), ("'updated", '2012-01-02T00:00:00+00:00'), ("'content", ("'info", ("'description", 'app2'))))),)419 return True420if __name__ == '__main__':421 print 'Testing...'422 testUser()423 testAccounts()424 testPictures()425 testPages()426 testComposites()427 testIcons()428 testApps()429 testStore()430 testDashboards()431 testReviews()432 testRatings()433 testSelector()434 testSearch()...

Full Screen

Full Screen

Android_lancher_unit_test.py

Source:Android_lancher_unit_test.py Github

copy

Full Screen

1import autotestunit2import time3case_1 = [ 4 {'point':['app1_0','app1_a'], 'check':[ ['app1','main'] ] } ,5 {'point':['back_0','back_a'], 'check':[ [ 'app1','null' ] ] } 6 ]7case_2 = [ 8 {'point':['app1_0','app1_a'], 'check':[ ['app1','main'] ] } ,9 {'point':['home'], 'check':[ [ 'app1','pip' ] ] } ,10 {'point':['app1_0','app1_a'], 'check':[ ['app1','main'] ] } ,11 {'point':['back_0','back_a'], 'check':[ [ 'app1','null' ] ] } 12 ]13case_3 = [ 14 {'point':['app1_0','app1_a'], 'check':[ ['app1','main'] ] } ,15 {'point':['home'], 'check':[ [ 'app1','pip' ] ] } ,16 {'point':['app1_0','app1_a'], 'check':[ ['app1','main'] ] } ,17 {'point':['back_0','back_a'], 'check':[ [ 'app1','null' ] ] } 18 ]19case_4 = [ 20 {'point':['app1_0','app1_a'], 'check':[ ['app1','main'] ] } ,21 {'point':['home'], 'check':[ [ 'app1','pip' ] ] } ,22 {'point':['home'], 'check':[ ['app1','main'] ] } ,23 {'point':['back_0','back_a'], 'check':[ [ 'app1','null' ] ] } 24 ] #????25case_5 = [ 26 {'point':['app1_0','app1_a'], 'check':[ ['app1','main'] ] } ,27 {'point':['home'], 'check':[ [ 'app1','pip' ] ] } ,28 {'point':['app1_0','app1_b'], 'check':[ ['app1','extend'] ] } ,29 {'point':['home'], 'check':[ [ 'app1','extend' ] ] } ,30 {'point':['back_0','back_b'], 'check':[ [ 'app1','null' ] ] } 31 ]32case_6 = [ 33 {'point':['app1_0','app1_a'], 'check':[ ['app1','main'] ] } ,34 {'point':['home'], 'check':[ [ 'app1','pip' ] ] } ,35 {'point':['app1_0','app1_b'], 'check':[ ['app1','extend'] ] } ,36 {'point':['back_0','back_a'], 'check':[ [ 'app1','extend' ] ] } ,37 {'point':['back_0','back_b'], 'check':[ ['app1','null'] ] } 38 ]39case_7 = [ 40 {'point':['app1_0','app1_a'], 'check':[ ['app1','main'] ] } ,41 {'point':['home'], 'check':[ [ 'app1','pip' ] ] } ,42 {'point':['app1_0','app1_b'], 'check':[ ['app1','extend'] ] } ,43 {'point':['back_0','back_b'], 'check':[ [ 'app1','null' ] ] } 44 ]45case_8 = [ 46 {'point':['app1_0','app1_a'], 'check':[ ['app1','main'] ] } ,47 {'point':['home'] , 'check':[ [ 'app1','pip' ] ] } ,48 {'point':['app1_0','app1_b'], 'check':[ ['app1','extend'] ] } ,49 {'point':['app1_0','app1_a'], 'check':[ [ 'app1','main' ] ] } ,50 {'point':['back_0','back_a'], 'check':[ [ 'app1','null' ] ] } 51 52 ]53case_9 = [ 54 {'point':['app1_0','app1_a'], 'check':[ ['app1','main'] ] } ,55 {'point':['home'], 'check':[ [ 'app1','pip' ] ] } ,56 {'point':['app1_0','app1_b'], 'check':[ ['app1','extend'] ] } ,57 {'point':['back_0','back_b'], 'check':[ [ 'app1','null' ] ] } 58 ]59case_10 = [ 60 {'point':['app1_0','app1_a'], 'check':[ ['app1','main'] ] } ,61 {'point':['home'], 'check':[ [ 'app1','pip' ] ] } ,62 {'point':['app1_0','app1_b'], 'check':[ ['app1','extend'] ] } ,63 {'point':['app2_0','app2_a'], 'check':[ ['app1','extend'],['app2','main'] ] } ,64 {'point':['home'], 'check':[ ['app2','pip'] ,['app1','extend'] ] } ,65 66 67 {'point':['back_0','back_a'], 'check':[ ['app2','pip'] ,['app1','extend'] ] } ,68 {'point':['app2_0','app2_a'], 'check':[ ['app2','main'],['app1','extend'] ] } ,69 {'point':['back_0','back_a'], 'check':[ ['app2','null'],['app1','extend'] ] } ,70 {'point':['back_0','back_b'], 'check':[ ['app1','null'] ] } 71 72 ]73case_11 = [ 74 {'point':['app1_0','app1_a'], 'check':[ ['app1','main'] ] } ,75 {'point':['home'], 'check':[ [ 'app1','pip' ] ] } ,76 {'point':['app1_0','app1_b'], 'check':[ ['app1','extend'] ] } ,77 {'point':['app2_0','app2_a'], 'check':[ ['app1','extend'],['app2','main'] ] } ,78 {'point':['home'], 'check':[ ['app2','pip'] ,['app1','extend'] ] } ,79 80 81 {'point':['back_0','back_b'], 'check':[ ['app2','pip'] ,['app1','null'] ] } ,82 {'point':['home'], 'check':[ ['app2','main']] } ,83 {'point':['back_0','back_a'], 'check':[ ['app2','null'] ] } 84 ]85case_12 = [ 86 {'point':['app1_0','app1_a'], 'check':[ ['app1','main'] ] } , 87 {'point':['home'], 'check':[ [ 'app1','pip' ] ] } ,88 {'point':['app1_0','app1_b'], 'check':[ ['app1','extend'] ] } ,89 {'point':['app2_0','app2_a'], 'check':[ ['app1','extend'],['app2','main'] ] } ,90 {'point':['home'], 'check':[ ['app2','pip'] ,['app1','extend'] ] } , 91 92 {'point':['home'], 'check':[ ['app2','main'] ,['app1','extend'] ] } ,93 {'point':['back_0','back_a'], 'check':[ ['app2','null'],['app1','extend'] ] } ,94 {'point':['back_0','back_b'], 'check':[ ['app1','null'] ] } 95 ]96case_13 = [ 97 {'point':['app1_0','app1_a'],'check':[ ['app1','main'] ] } ,98 {'point':['home'],'check':[ [ 'app1','pip' ] ] } ,99 {'point':['app1_0','app1_b'],'check':[ ['app1','extend'] ] } ,100 {'point':['app2_0','app2_a'],'check':[ ['app1','extend'],['app2','main'] ] } ,101 {'point':['home'],'check':[ ['app2','pip'] ,['app1','extend'] ] } ,102 103 104 {'point':['app1_0','app1_a'],'check':[ ['app1','main'] ,['app2','null'] ] } ,105 {'point':['back_0','back_a'],'check':[ ['app2','null'] ] }106 ]107case_14 = [ 108 {'point':['app1_0','app1_a'],'check':[ ['app1','main'] ] } ,109 {'point':['home'],'check':[ [ 'app1','pip' ] ] } ,110 {'point':['app1_0','app1_b'],'check':[ ['app1','extend'] ] } ,111 {'point':['app2_0','app2_a'],'check':[ ['app1','extend'],['app2','main'] ] } ,112 {'point':['home'],'check':[ ['app2','pip'] ,['app1','extend'] ] } ,113 114 115 {'point':['app1_0','app1_b'],'check':[ ['app1','extend'] ,['app2','pip'] ] } ,116 {'point':['back_0','back_b'],'check':[ ['app1','null'] ,['app2','pip'] ] } ,117 {'point':['app2_0','app2_a'],'check':[ ['app2','main'] ] } ,118 {'point':['back_0','back_a'],'check':[ ['app2','null'] ] }119 ]120case_15 = [ 121 {'point':['app1_0','app1_a'],'check':[ ['app1','main'] ] } ,122 {'point':['home'],'check':[ [ 'app1','pip' ] ] } ,123 {'point':['app1_0','app1_b'],'check':[ ['app1','extend'] ] } ,124 {'point':['app2_0','app2_a'],'check':[ ['app1','extend'],['app2','main'] ] } ,125 {'point':['home'],'check':[ ['app2','pip'] ,['app1','extend'] ] } ,126 127 {'point':['app2_0','app2_a'],'check':[ ['app1','extend'] ,['app2','main'] ] } ,128 {'point':['back_0','back_b'],'check':[ ['app1','null'] ,['app2','main'] ] } ,129 {'point':['back_0','back_a'],'check':[ ['app2','null'] ] }130 ]131case_16 = [ 132 {'point':['app1_0','app1_a'],'check':[ ['app1','main'] ] } ,133 {'point':['home'],'check':[ [ 'app1','pip' ] ] } ,134 {'point':['app1_0','app1_b'],'check':[ ['app1','extend'] ] } ,135 {'point':['app2_0','app2_a'],'check':[ ['app1','extend'],['app2','main'] ] } ,136 {'point':['home'],'check':[ ['app2','pip'] ,['app1','extend'] ] } ,137 138 139 {'point':['app2_0','app2_b'],'check':[ ['app2','extend'] ,['app1','null'] ] } ,140 {'point':['back_0','back_b'],'check':[ ['app2','null'] ] }141 ]142case_17 = [ 143 {'point':['app1_0','app1_a'],'check':[ ['app1','main'] ] } ,144 {'point':['home'],'check':[ [ 'app1','pip' ] ] } ,145 {'point':['app1_0','app1_b'],'check':[ ['app1','extend'] ] } ,146 {'point':['app2_0','app2_a'],'check':[ ['app1','extend'],['app2','main'] ] } ,147 {'point':['home'],'check':[ ['app2','pip'] ,['app1','extend'] ] } ,148 149 150 {'point':['app3_0','app3_a'],'check':[ ['app3','main'] ,['app1','extend'],['app2','null'] ] } ,151 {'point':['back_0','back_a'],'check':[ ['app3','null'],['app1','extend'] ] },152 {'point':['back_0','back_b'],'check':[ ['app1','null'] ] }153 ]154case_18 = [ 155 {'point':['app1_0','app1_a'],'check':[ ['app1','main'] ] } ,156 {'point':['home'],'check':[ [ 'app1','pip' ] ] } ,157 {'point':['app1_0','app1_b'],'check':[ ['app1','extend'] ] } ,158 {'point':['app2_0','app2_a'],'check':[ ['app1','extend'],['app2','main'] ] } ,159 {'point':['home'],'check':[ ['app2','pip'] ,['app1','extend'] ] } ,160 161 162 {'point':['app3_0','app3_b'],'check':[ ['app2','pip'] ,['app3','extend'],['app1','null'] ] } ,163 {'point':['app2_0','app2_a'],'check':[ ['app2','main'],['app3','extend'] ] },164 {'point':['back_0','back_a'],'check':[ ['app2','null'],['app3','extend'] ] },165 {'point':['back_0','back_b'],'check':[ ['app3','null'] ] }166 ]167case_19 = [ 168 {'point':['app1_0','app1_a'],'check':[ ['app1','main'] ] } ,169 {'point':['home'],'check':[ [ 'app1','pip' ] ] } ,170 {'point':['app1_0','app1_b'],'check':[ ['app1','extend'] ] } ,171 {'point':['app2_0','app2_a'],'check':[ ['app1','extend'],['app2','main'] ] } ,172 {'point':['back_0','back_a'],'check':[ ['app2','null'] ,['app1','extend'] ] } ,173 {'point':['back_0','back_b'],'check':[ ['app1','null'] ] }174 ]175case_20 = [ 176 {'point':['app1_0','app1_a'],'check':[ ['app1','main'] ] } ,177 {'point':['home'],'check':[ [ 'app1','pip' ] ] } ,178 {'point':['app1_0','app1_b'],'check':[ ['app1','extend'] ] } ,179 {'point':['app2_0','app2_a'],'check':[ ['app1','extend'],['app2','main'] ] } ,180 181 182 {'point':['back_0','back_b'],'check':[ ['app2','main'] ,['app1','null'] ] } ,183 {'point':['back_0','back_a'],'check':[ ['app2','null'] ] }184 ]185case_21 = [ 186 {'point':['app1_0','app1_a'],'check':[ ['app1','main'] ] } ,187 {'point':['home'],'check':[ [ 'app1','pip' ] ] } ,188 {'point':['app1_0','app1_b'],'check':[ ['app1','extend'] ] } ,189 190 191 {'point':['app2_0','app2_b'],'check':[ ['app2','extend'] ] } ,192 193 194 {'point':['back_0','back_b'],'check':[ ['app2','null'] ] } 195 ]196case_22 = [ 197 {'point':['app1_0','app1_a'],'check':[ ['app1','main'] ] } ,198 {'point':['home'],'check':[ [ 'app1','pip' ] ] } ,199 200 {'point':['app2_0','app2_a'],'check':[ ['app1','null'],['app2','main'] ] } ,201 202 203 {'point':['back_0','back_a'], 'check':[ ['app2','null'] ] } 204 ]205case_23 = [ 206 {'point':['app1_0','app1_a'], 'check':[ ['app1','main'] ] } ,207 {'point':['home'],'check':[ [ 'app1','pip' ] ] } ,208 209 {'point':['app2_0','app2_b'],'check':[ ['app1','pip'],['app2','extend'] ] } ,210 211 {'point':['home',], 'check':[ ['app1','main'],['app2','extend'] ] } ,212 213 {'point':['back_0','back_a'], 'check':[ ['app1','null'],['app2','extend'] ] } ,214 {'point':['back_0','back_b'], 'check':[ ['app2','null'] ] } 215 ]216case_24 = [ 217 {'point':['app1_0','app1_a'], 'check':[ ['app1','main'] ] } ,218 {'point':['home'], 'check':[ [ 'app1','pip' ] ] } ,219 220 {'point':['home'], 'check':[ ['app1','main'] ] } ,221 {'point':['back_0','back_a'], 'check':[ [ 'app1','null' ] ] } 222 ]223case_25 = [ 224 {'point':['app1_0','app1_a'], 'check':[ ['app1','main'] ] } ,225 {'point':['home'], 'check':[ [ 'app1','pip' ] ] } ,226 227 {'point':['back_0','back_a'], 'check':[ ['app1','pip'] ] } ,228 {'point':['home'], 'check':[ [ 'app1','main' ] ] } ,229 {'point':['back_0','back_a'],'check':[ [ 'app1','null' ] ] } 230 ]231case_26 = [ 232 {'point':['app1_0','app1_a'],'check':[ ['app1','main'] ] } ,233 {'point':['home'],'check':[ [ 'app1','pip' ] ] } ,234 235 {'point':['back_0','back_b'],'check':[ ['app1','pip'] ] } ,236 {'point':['home'],'check':[ [ 'app1','main' ] ] } ,237 {'point':['back_0','back_a'],'check':[ [ 'app1','null' ] ] } 238 ]239case_27 = [ 240 {'point':['home',],'check':[ ] } 241 ]242case_28 = [ 243 {'point':['home',],'check':[ ] } 244 ]245case_29 = [ 246 {'point':['back_0','back_a'],'check':[ ] } 247 ]248case_30 = [ 249 {'point':['back_0','back_b'],'check':[ ] } 250 ]251case_31 = [ 252 {'point':['app1_0','app1_b'],'check':[ ['app1','extend'] ] } ,253 {'point':['back_0','back_b'],'check':[ [ 'app1','null' ] ] } 254 ]255case_32 = [ 256 {'point':['back_0','back_b'],'check':[ ] } 257 ]258case_0 = [ 259 {'point':['back_0','back_b'],'check':[ ] } 260 ]261test_case = [case_0,case_1,case_2,case_3,case_4,case_5,case_6,case_7,case_8,case_9,\262 case_10,case_11,case_12,case_13,case_14,case_15,case_16,case_17,case_18,case_19,\263 case_20,case_21,case_22,case_23,case_24,case_25,case_26,case_27,case_28,case_29,\264 case_30,case_31,case_32]265class Android_lancher_unit_test :266 def __init__(self):267 print 'hello world'268 self.unit = autotestunit.AutoTestUnit()269 def Android_Lancher_Test_Unit(self,case):270 print test_case[ ( case ) ]271 action = 1;272 for unit in test_case[ ( case )] : 273 print '\ntest uint +++++++++ %d --> %s \n' %(action ,unit) 274 action = action +1 275 state = self.unit.test_action(unit)276 if state == False :277 return 'FAIL'278 if state :279 return 'PASS'280 281if __name__ == '__main__':282 print 'hello'283 test = Android_lancher_unit_test()...

Full Screen

Full Screen

test_compatibility.py

Source:test_compatibility.py Github

copy

Full Screen

1from django.contrib.auth import get_user_model2from django.test import TestCase3from nextcloudappstore.core.models import App, AppRelease, NextcloudRelease4class CompatibilityTest(TestCase):5 def setUp(self):6 self.user = get_user_model().objects.create_user(username='test',7 password='test',8 email='test@test.com')9 self.platform_versions = ['9.0.0', '9.0.5', '10.0.0', '11.0.0',10 '12.0.0', '13.0.0']11 self.app1 = App.objects.create(pk='news', owner=self.user)12 self.app1.set_current_language('en')13 self.app1.name = 'News'14 self.app1.description = 'RSS feed reader'15 self.app1.save()16 def tearDown(self):17 if hasattr(self, 'app1'):18 self.app1.delete()19 if hasattr(self, 'app2'):20 self.app2.delete()21 self.user.delete()22 def test_compatible_apps_deduplication(self):23 AppRelease.objects.create(app=self.app1, version='1.0.0',24 platform_version_spec='>=9.0.0,<10.0.0')25 AppRelease.objects.create(app=self.app1, version='2.0.0',26 platform_version_spec='>=10.0.0,<11.0.0')27 AppRelease.objects.create(app=self.app1, version='3.0.0',28 platform_version_spec='>=10.0.0,<11.0.0')29 NextcloudRelease.objects.create(version='9.0.0')30 NextcloudRelease.objects.create(version='9.0.1')31 NextcloudRelease.objects.create(version='9.0.2')32 NextcloudRelease.objects.create(version='10.0.0')33 releases = self.app1.releases_by_platform_v()34 self.assertEqual(1, len(releases['9']))35 self.assertEqual(2, len(releases['10']))36 def test_compatible_apps(self):37 self._create_example_releases()38 apps = App.objects.get_compatible('12.0.0')39 apps2 = App.objects.get_compatible('11.0.0')40 apps3 = App.objects.get_compatible('10.0.0')41 apps4 = App.objects.get_compatible('9.0.0')42 self.assertEqual(len(apps), 1)43 self.assertEqual(apps[0].id, self.app1.id)44 self.assertEqual(len(apps2), 2)45 self.assertEqual(len(apps3), 2)46 self.assertEqual(len(apps4), 2)47 def test_compatible_releases(self):48 self._create_example_releases()49 app1rel = self.app1.compatible_releases('12.0.0')50 app1rel2 = self.app1.compatible_releases('9.0.0')51 app2rel = self.app2.compatible_releases('10.0.0')52 app2rel2 = self.app2.compatible_releases('9.0.0')53 self.assertEqual(len(app1rel), 2)54 self.assertEqual(len(app1rel2), 1)55 self.assertEqual(len(app2rel), 1)56 self.assertEqual(len(app2rel2), 1)57 def test_compatible_unstable_releases(self):58 self._create_example_releases()59 app1 = self.app1.compatible_unstable_releases('12.0')60 app2 = self.app2.compatible_unstable_releases('12.0')61 self.assertEqual(app1[0].version, '6.0.0')62 self.assertEqual(app1[0].is_nightly, True)63 self.assertEqual(app1[1].version, '6.0.0-alpha')64 self.assertEqual(len(app1), 2)65 self.assertEqual(app2, [])66 def test_compatible_releases_by_platform_v(self):67 self._create_example_releases()68 self._create_nextcloud_versions()69 app1 = self.app1.latest_releases_by_platform_v()70 app2 = self.app2.latest_releases_by_platform_v()71 self.assertEqual(app1['9']['stable'].version, '2.0.0')72 self.assertEqual(app1['9']['unstable'], None)73 self.assertEqual(app1['10']['stable'].version, '3.0.0')74 self.assertEqual(app1['10']['unstable'], None)75 self.assertEqual(app1['11']['stable'].version, '4.0.0')76 self.assertEqual(app1['11']['unstable'], None)77 self.assertEqual(app1['12']['stable'].version, '5.0.0')78 self.assertEqual(app1['12']['unstable'].version, '6.0.0')79 self.assertEqual(app1['12']['unstable'].is_nightly, True)80 self.assertEqual(app2['9']['stable'].version, '1.0.0')81 self.assertEqual(app2['10']['stable'].version, '2.0.0')82 self.assertEqual(app2['11']['stable'].version, '4.0.0')83 self.assertEqual(app2['12']['stable'], None)84 def test_correct_comparison(self):85 self._create_example_releases()86 self._create_nextcloud_versions()87 app1 = self.app1.latest_releases_by_platform_v()88 self.assertEqual(app1['10']['stable'].version, '3.0.0')89 self.assertEqual(app1['12']['unstable'].version, '6.0.0')90 def _create_nextcloud_versions(self):91 for version in self.platform_versions:92 NextcloudRelease.objects.create(version=version)93 def _create_example_releases(self):94 AppRelease.objects.create(app=self.app1, version='1.0.0',95 platform_version_spec='>=9.0.0,<10.0.0')96 AppRelease.objects.create(app=self.app1, version='2.0.0',97 platform_version_spec='>=9.0.5,<10.0.5')98 AppRelease.objects.create(app=self.app1, version='3.0.0',99 platform_version_spec='>=10.0.0,<12.0.0')100 AppRelease.objects.create(app=self.app1, version='4.0.0',101 platform_version_spec='>=11.0.0')102 AppRelease.objects.create(app=self.app1, version='5.0.0',103 platform_version_spec='>=12.0.0')104 AppRelease.objects.create(app=self.app1, version='6.0.0-alpha',105 platform_version_spec='>=12.0.0')106 AppRelease.objects.create(app=self.app1, version='6.0.0',107 platform_version_spec='>=12.0.0',108 is_nightly=True)109 self.app2 = App.objects.create(pk='notes', owner=self.user)110 self.app2.set_current_language('en')111 self.app2.name = 'Notes'112 self.app2.description = 'Notes application'113 self.app2.save()114 AppRelease.objects.create(app=self.app2, version='1.0.0',115 platform_version_spec='>=9.0.0,<10.0.0')116 AppRelease.objects.create(app=self.app2, version='2.0.0',117 platform_version_spec='>=10.0.0,<11.0.0')118 AppRelease.objects.create(app=self.app2, version='3.0.0',119 platform_version_spec='>=11.0.0,<12.0.0')120 AppRelease.objects.create(app=self.app2, version='4.0.0',...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful