<s> from changes . config import db <EOL> from changes . models import SnapshotImage , SnapshotStatus <EOL> from changes . testutils import APITestCase <EOL> class SnapshotImageDetailsTest ( APITestCase ) : <EOL> def test_simple ( self ) : <EOL> project = self . create_project ( ) <EOL> build = self . create_build ( project = project ) <EOL> snapshot = self . create_snapshot ( project , build = build ) <EOL> plan = self . create_plan ( project ) <EOL> image = self . create_snapshot_image ( snapshot , plan ) <EOL> path = '<STR_LIT>' . format ( image . id ) <EOL> resp = self . client . get ( path ) <EOL> assert resp . status_code == <NUM_LIT:200> <EOL> data = self . unserialize ( resp ) <EOL> assert data [ '<STR_LIT:id>' ] == image . id . hex <EOL> class UpdateSnapshotImageTest ( APITestCase ) : <EOL> def setUp ( self ) : <EOL> super ( UpdateSnapshotImageTest , self ) . setUp ( ) <EOL> self . project = self . create_project ( ) <EOL> build = self . create_build ( project = self . project ) <EOL> self . snapshot = self . create_snapshot ( self . project , build = build ) <EOL> self . plan = self . create_plan ( self . project ) <EOL> self . image = self . create_snapshot_image ( self . snapshot , self . plan ) <EOL> self . path = '<STR_LIT>' . format ( self . image . id ) <EOL> def test_simple ( self ) : <EOL> for status in ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) : <EOL> resp = self . client . post ( self . path , data = { <EOL> '<STR_LIT:status>' : status , <EOL> } ) <EOL> assert resp . status_code == <NUM_LIT:200> <EOL> data = self . unserialize ( resp ) <EOL> assert data [ '<STR_LIT:id>' ] == self . image . id . hex <EOL> assert data [ '<STR_LIT:status>' ] [ '<STR_LIT:id>' ] == status <EOL> db . session . expire ( self . image ) <EOL> image = SnapshotImage . query . get ( self . image . id ) <EOL> assert image . status == SnapshotStatus [ status ] <EOL> def test_invalid_status ( self ) : <EOL> resp = self . client . post ( self . path , data = { <EOL> '<STR_LIT:status>' : '<STR_LIT>' , <EOL> } ) <EOL> assert resp . status_code == <NUM_LIT> </s>
