<s> import unittest <EOL> from pyramid import testing <EOL> class TestPasteBin ( unittest . TestCase ) : <EOL> def _makeOne ( self , * arg , ** kw ) : <EOL> from cluegun . models import PasteBin <EOL> return PasteBin ( * arg , ** kw ) <EOL> def test_add_paste ( self ) : <EOL> pastebin = self . _makeOne ( ) <EOL> entry = testing . DummyResource ( ) <EOL> pastebin . add_paste ( entry ) <EOL> self . assertEqual ( pastebin [ <NUM_LIT:0> ] , entry ) <EOL> self . assertEqual ( pastebin . current_id , <NUM_LIT:0> ) <EOL> class TestPasteEntry ( unittest . TestCase ) : <EOL> def _makeOne ( self , author_name , paste , language ) : <EOL> from cluegun . models import PasteEntry <EOL> return PasteEntry ( author_name , paste , language ) <EOL> def test_ctor ( self ) : <EOL> entry = self . _makeOne ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . assertEqual ( entry . author_name , '<STR_LIT>' ) <EOL> self . assertEqual ( entry . paste , '<STR_LIT>' ) <EOL> self . assertEqual ( entry . language , '<STR_LIT>' ) <EOL> self . failUnless ( entry . date ) <EOL> class Test_appmaker ( unittest . TestCase ) : <EOL> def _callFUT ( self , root , txn ) : <EOL> from cluegun . models import appmaker <EOL> return appmaker ( root , txn ) <EOL> def test_already_exists ( self ) : <EOL> root = { '<STR_LIT>' : '<STR_LIT:abc>' } <EOL> txn = DummyTransaction ( ) <EOL> result = self . _callFUT ( root , txn ) <EOL> self . assertEqual ( result , '<STR_LIT:abc>' ) <EOL> self . failIf ( txn . committed ) <EOL> def test_doesnt_exist ( self ) : <EOL> from cluegun . models import PasteBin <EOL> root = { } <EOL> txn = DummyTransaction ( ) <EOL> result = self . _callFUT ( root , txn ) <EOL> self . assertEqual ( result . __class__ , PasteBin ) <EOL> self . failUnless ( txn . committed ) <EOL> class DummyTransaction ( object ) : <EOL> committed = False <EOL> def commit ( self ) : <EOL> self . committed = True </s>
