<s> '''<STR_LIT>''' <EOL> from django . test . client import Client <EOL> from django . utils import unittest <EOL> from django . core . management import call_command <EOL> from puppet . models import Host , Resource , FactValue , Fact <EOL> from updates . models import Package , Update <EOL> Host . _meta . managed = True <EOL> Resource . _meta . managed = True <EOL> FactValue . _meta . managed = True <EOL> Fact . _meta . managed = True <EOL> class UpdatesTestCase ( unittest . TestCase ) : <EOL> '''<STR_LIT>''' <EOL> def setUp ( self ) : <EOL> '''<STR_LIT>''' <EOL> self . host1 = Host . objects . create ( name = '<STR_LIT>' , ip = '<STR_LIT>' ) <EOL> self . package1 = Package . objects . create ( name = '<STR_LIT>' , sourcename = '<STR_LIT>' ) <EOL> self . package2 = Package . objects . create ( name = '<STR_LIT>' , sourcename = '<STR_LIT>' ) <EOL> self . update1 = Update . objects . create ( <EOL> package = self . package1 , host = self . host1 , <EOL> installedVersion = '<STR_LIT>' , candidateVersion = '<STR_LIT>' , <EOL> source = '<STR_LIT>' , origin = '<STR_LIT>' ) <EOL> self . update2 = Update . objects . create ( <EOL> package = self . package2 , host = self . host1 , <EOL> installedVersion = '<STR_LIT>' , candidateVersion = '<STR_LIT>' , <EOL> source = '<STR_LIT>' , origin = '<STR_LIT>' ) <EOL> self . update3 = Update . objects . create ( <EOL> package = self . package2 , host = self . host1 , <EOL> installedVersion = '<STR_LIT>' , candidateVersion = '<STR_LIT>' , <EOL> source = '<STR_LIT>' , origin = '<STR_LIT:None>' ) <EOL> def tearDown ( self ) : <EOL> '''<STR_LIT>''' <EOL> Host . objects . all ( ) . delete ( ) <EOL> Package . objects . all ( ) . delete ( ) <EOL> Update . objects . all ( ) . delete ( ) <EOL> def test_if_host_equal ( self ) : <EOL> self . assertEqual ( self . update1 . host . name , self . package1 . hosts . all ( ) [ <NUM_LIT:0> ] . name ) <EOL> def test_unicode ( self ) : <EOL> self . assertIsInstance ( str ( self . host1 ) , str ) <EOL> self . assertIsInstance ( str ( self . package1 ) , str ) <EOL> self . assertIsInstance ( str ( self . package2 ) , str ) <EOL> self . assertIsInstance ( str ( self . update1 ) , str ) <EOL> self . assertIsInstance ( self . update1 . get_changelog_url ( ) , str ) <EOL> self . assertIsInstance ( str ( self . update2 ) , str ) <EOL> self . assertIsInstance ( self . update2 . get_changelog_url ( ) , str ) <EOL> self . assertIsInstance ( str ( self . update3 ) , str ) <EOL> self . assertIsNone ( self . update3 . get_changelog_url ( ) ) <EOL> class ViewsTestCase ( unittest . TestCase ) : <EOL> '''<STR_LIT>''' <EOL> def setUp ( self ) : <EOL> '''<STR_LIT>''' <EOL> from hwdoc . tests import EquipmentTestCase <EOL> EquipmentTestCase . dummy = lambda x : True <EOL> self . etc = EquipmentTestCase ( '<STR_LIT>' ) <EOL> self . etc . setUp ( ) <EOL> self . package1 = Package . objects . create ( name = '<STR_LIT>' , sourcename = '<STR_LIT>' ) <EOL> self . package2 = Package . objects . create ( name = '<STR_LIT>' , sourcename = '<STR_LIT>' ) <EOL> self . host1 = Host . objects . create ( name = '<STR_LIT>' , ip = '<STR_LIT>' ) <EOL> self . host2 = Host . objects . create ( name = '<STR_LIT>' , ip = '<STR_LIT>' ) <EOL> self . host3 = Host . objects . create ( name = '<STR_LIT>' , ip = '<STR_LIT>' ) <EOL> self . fact1 = Fact . objects . create ( name = '<STR_LIT>' ) <EOL> self . fact2 = Fact . objects . create ( name = '<STR_LIT>' ) <EOL> self . fact3 = Fact . objects . create ( name = '<STR_LIT>' ) <EOL> self . fact4 = Fact . objects . create ( name = '<STR_LIT>' ) <EOL> self . fact5 = Fact . objects . create ( name = '<STR_LIT>' ) <EOL> self . fact6 = Fact . objects . create ( name = '<STR_LIT>' ) <EOL> self . factvalue1 = FactValue . objects . create ( <EOL> value = '<STR_LIT>' , <EOL> fact_name = self . fact1 , host = self . host1 ) <EOL> self . factvalue2 = FactValue . objects . create ( <EOL> value = '<STR_LIT>' , <EOL> fact_name = self . fact2 , host = self . host1 ) <EOL> self . factvalue3 = FactValue . objects . create ( <EOL> value = '<STR_LIT>' , <EOL> fact_name = self . fact3 , host = self . host1 ) <EOL> self . factvalue4 = FactValue . objects . create ( <EOL> value = '<STR_LIT>' , <EOL> fact_name = self . fact4 , host = self . host1 ) <EOL> self . factvalue5 = FactValue . objects . create ( <EOL> value = '<STR_LIT>' , <EOL> fact_name = self . fact5 , host = self . host1 ) <EOL> self . factvalue6 = FactValue . objects . create ( <EOL> value = '<STR_LIT>' , <EOL> fact_name = self . fact6 , host = self . host2 ) <EOL> self . factvalue7 = FactValue . objects . create ( <EOL> value = '<STR_LIT>' , <EOL> fact_name = self . fact6 , host = self . host3 ) <EOL> self . update1 = Update . objects . create ( <EOL> package = self . package1 , host = self . host1 , <EOL> installedVersion = '<STR_LIT>' , candidateVersion = '<STR_LIT>' , <EOL> source = '<STR_LIT>' , origin = '<STR_LIT>' ) <EOL> self . update2 = Update . objects . create ( <EOL> package = self . package2 , host = self . host1 , is_security = True , <EOL> installedVersion = '<STR_LIT>' , candidateVersion = '<STR_LIT>' , <EOL> source = '<STR_LIT>' , origin = '<STR_LIT>' ) <EOL> def tearDown ( self ) : <EOL> '''<STR_LIT>''' <EOL> Package . objects . all ( ) . delete ( ) <EOL> Update . objects . all ( ) . delete ( ) <EOL> Host . objects . all ( ) . delete ( ) <EOL> Fact . objects . all ( ) . delete ( ) <EOL> FactValue . objects . all ( ) . delete ( ) <EOL> self . etc . tearDown ( ) <EOL> def test_hostlist ( self ) : <EOL> c = Client ( ) <EOL> response = c . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> def test_packagelist ( self ) : <EOL> c = Client ( ) <EOL> response = c . get ( '<STR_LIT>' ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> def test_empty_package ( self ) : <EOL> c = Client ( ) <EOL> data = [ '<STR_LIT>' ] <EOL> for d in data : <EOL> response = c . get ( '<STR_LIT>' % d ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> def test_nonexistent_package ( self ) : <EOL> c = Client ( ) <EOL> data = [ '<STR_LIT>' ] <EOL> for d in data : <EOL> response = c . get ( '<STR_LIT>' % d ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT> ) <EOL> def test_existent_package ( self ) : <EOL> c = Client ( ) <EOL> data = [ self . package1 . name , self . package2 . name ] <EOL> for d in data : <EOL> response = c . get ( '<STR_LIT>' % d ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> def test_existent_package_plaintext ( self ) : <EOL> c = Client ( ) <EOL> data = [ self . package1 . name , self . package2 . name ] <EOL> for d in data : <EOL> response = c . get ( '<STR_LIT>' % d , { '<STR_LIT>' : '<STR_LIT:yes>' } ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> def test_empty_host ( self ) : <EOL> c = Client ( ) <EOL> response = c . get ( '<STR_LIT>' % '<STR_LIT>' ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> def test_nonexistent_host ( self ) : <EOL> c = Client ( ) <EOL> response = c . get ( '<STR_LIT>' % '<STR_LIT>' ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT> ) <EOL> def test_existent_host ( self ) : <EOL> c = Client ( ) <EOL> data = [ self . host1 . name , self . host2 . name , self . host3 . name ] <EOL> for d in data : <EOL> response = c . get ( '<STR_LIT>' % d ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> def test_existent_host_without_interfaces ( self ) : <EOL> c = Client ( ) <EOL> data = [ self . host2 . name ] <EOL> for d in data : <EOL> response = c . get ( '<STR_LIT>' % d ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> class CommandsTestCase ( unittest . TestCase ) : <EOL> '''<STR_LIT>''' <EOL> def setUp ( self ) : <EOL> '''<STR_LIT>''' <EOL> self . package1 = Package . objects . create ( name = '<STR_LIT>' , sourcename = '<STR_LIT>' ) <EOL> self . package2 = Package . objects . create ( name = '<STR_LIT>' , sourcename = '<STR_LIT>' ) <EOL> self . host1 = Host . objects . create ( name = '<STR_LIT>' , ip = '<STR_LIT>' ) <EOL> self . host2 = Host . objects . create ( name = '<STR_LIT>' , ip = '<STR_LIT>' ) <EOL> self . fact1 = Fact . objects . create ( name = '<STR_LIT>' ) <EOL> self . fact2 = Fact . objects . create ( name = '<STR_LIT>' ) <EOL> self . fact3 = Fact . objects . create ( name = '<STR_LIT>' ) <EOL> self . fact4 = Fact . objects . create ( name = '<STR_LIT>' ) <EOL> self . fact5 = Fact . objects . create ( name = '<STR_LIT>' ) <EOL> self . fact6 = Fact . objects . create ( name = '<STR_LIT>' ) <EOL> self . factvalue1 = FactValue . objects . create ( <EOL> value = '<STR_LIT>' , <EOL> fact_name = self . fact1 , host = self . host1 ) <EOL> self . factvalue2 = FactValue . objects . create ( <EOL> value = '<STR_LIT>' , <EOL> fact_name = self . fact2 , host = self . host1 ) <EOL> self . factvalue3 = FactValue . objects . create ( <EOL> value = '<STR_LIT>' , <EOL> fact_name = self . fact3 , host = self . host1 ) <EOL> self . factvalue4 = FactValue . objects . create ( <EOL> value = '<STR_LIT>' , <EOL> fact_name = self . fact4 , host = self . host1 ) <EOL> self . factvalue5 = FactValue . objects . create ( <EOL> value = '<STR_LIT>' , <EOL> fact_name = self . fact5 , host = self . host1 ) <EOL> v = """<STR_LIT>""" % self . host1 <EOL> self . factvalue6 = FactValue . objects . create ( <EOL> value = v , <EOL> fact_name = self . fact6 , host = self . host1 ) <EOL> def tearDown ( self ) : <EOL> '''<STR_LIT>''' <EOL> Package . objects . all ( ) . delete ( ) <EOL> Host . objects . all ( ) . delete ( ) <EOL> Fact . objects . all ( ) . delete ( ) <EOL> FactValue . objects . all ( ) . delete ( ) <EOL> Package . objects . all ( ) . delete ( ) <EOL> def test_make_updates ( self ) : <EOL> call_command ( '<STR_LIT>' ) <EOL> class MigrationsTestCase ( unittest . TestCase ) : <EOL> '''<STR_LIT>''' <EOL> def setUp ( self ) : <EOL> call_command ( '<STR_LIT>' , '<STR_LIT>' , <EOL> fake = True , verbosity = <NUM_LIT:0> , no_initial_data = True ) <EOL> call_command ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> verbosity = <NUM_LIT:0> , no_initial_data = True ) <EOL> def tearDown ( self ) : <EOL> call_command ( '<STR_LIT>' , '<STR_LIT>' , <EOL> verbosity = <NUM_LIT:0> , no_initial_data = True ) <EOL> def test_migrate_full_forwards ( self ) : <EOL> call_command ( '<STR_LIT>' , '<STR_LIT>' , <EOL> verbosity = <NUM_LIT:0> , no_initial_data = True ) <EOL> def test_migrate_full_backwards ( self ) : <EOL> call_command ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> verbosity = <NUM_LIT:0> , no_initial_data = True ) </s>
