<s> import unittest2 <EOL> import copy <EOL> from google . appengine . ext import testbed <EOL> from webapp2_extras import json <EOL> from core import model <EOL> class ModelTestCase ( unittest2 . TestCase ) : <EOL> fixture_widget = json . decode ( '<STR_LIT>' ) <EOL> def setUp ( self ) : <EOL> self . testbed = testbed . Testbed ( ) <EOL> self . testbed . activate ( ) <EOL> self . testbed . init_datastore_v3_stub ( ) <EOL> self . testbed . init_memcache_stub ( ) <EOL> def tearDown ( self ) : <EOL> self . testbed . deactivate ( ) <EOL> def test_create ( self ) : <EOL> widget = copy . copy ( self . fixture_widget ) <EOL> model . Widget . put ( widget ) <EOL> self . assertEqual ( <NUM_LIT:1> , len ( model . Widget . all ( ) . fetch ( <NUM_LIT:2> ) ) ) <EOL> def test_read ( self ) : <EOL> widget = copy . copy ( self . fixture_widget ) <EOL> widget [ '<STR_LIT>' ] = <NUM_LIT> <EOL> entity = model . Widget . put ( widget ) <EOL> self . assertNotEqual ( None , entity ) <EOL> entity = model . Widget . get ( entity . key ( ) . id ( ) ) <EOL> self . assertEqual ( entity . int_field , <NUM_LIT> ) <EOL> def test_update ( self ) : <EOL> widget = copy . copy ( self . fixture_widget ) <EOL> identifier = model . Widget . put ( widget ) . key ( ) . id ( ) <EOL> widget = copy . copy ( self . fixture_widget ) <EOL> widget [ '<STR_LIT>' ] = <NUM_LIT> <EOL> widget [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> widget [ '<STR_LIT>' ] = False <EOL> entity = model . Widget . post ( identifier , widget ) <EOL> self . assertEqual ( entity . int_field , <NUM_LIT> ) <EOL> self . assertEqual ( entity . email_field , '<STR_LIT>' ) <EOL> self . assertEqual ( entity . boolean_field , False ) <EOL> def test_delete ( self ) : <EOL> widget = copy . copy ( self . fixture_widget ) <EOL> identifier = model . Widget . put ( widget ) . key ( ) . id ( ) <EOL> self . assertEqual ( model . Widget . delete1 ( identifier ) , True ) <EOL> self . assertEqual ( <NUM_LIT:0> , len ( model . Widget . all ( ) . fetch ( <NUM_LIT:2> ) ) ) </s>
