<s> import mock <EOL> import os <EOL> from oslo_serialization import jsonutils <EOL> from six import StringIO <EOL> import yaml <EOL> from nailgun . db . sqlalchemy import fixman <EOL> from nailgun . db . sqlalchemy . models import Node <EOL> from nailgun . db . sqlalchemy . models import Release <EOL> from nailgun import objects <EOL> from nailgun . test . base import BaseIntegrationTest <EOL> from nailgun . test . base import DeploymentTasksTestMixin <EOL> class TestExtensionsCallback ( BaseIntegrationTest ) : <EOL> fixtures = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> def setUp ( self ) : <EOL> self . patcher = mock . patch ( <EOL> '<STR_LIT>' ) <EOL> self . callback_mock = self . patcher . start ( ) <EOL> self . addCleanup ( self . patcher . stop ) <EOL> super ( TestExtensionsCallback , self ) . setUp ( ) <EOL> def test_upload_working ( self ) : <EOL> self . assertEqual ( self . callback_mock . call_count , <NUM_LIT:8> ) <EOL> class TestFixture ( BaseIntegrationTest , DeploymentTasksTestMixin ) : <EOL> fixtures = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> maxDiff = None <EOL> def test_upload_working ( self ) : <EOL> check = self . db . query ( Node ) . all ( ) <EOL> self . assertEqual ( len ( list ( check ) ) , <NUM_LIT:8> ) <EOL> def test_load_fake_deployment_tasks ( self ) : <EOL> self . env . upload_fixtures ( [ "<STR_LIT>" ] ) <EOL> fxtr_path = os . path . join ( fixman . get_base_fixtures_path ( ) , <EOL> '<STR_LIT>' ) <EOL> with open ( fxtr_path ) as f : <EOL> deployment_tasks = yaml . load ( f ) <EOL> fixman . load_fake_deployment_tasks ( ) <EOL> for rel in self . db . query ( Release ) . all ( ) : <EOL> deployment_graph = objects . DeploymentGraph . get_for_model ( rel ) <EOL> db_deployment_tasks = objects . DeploymentGraph . get_tasks ( <EOL> deployment_graph ) <EOL> self . _compare_tasks ( deployment_tasks , db_deployment_tasks ) <EOL> def test_json_fixture ( self ) : <EOL> data = '''<STR_LIT>''' <EOL> fixman . upload_fixture ( StringIO ( data ) , loader = jsonutils ) <EOL> check = self . db . query ( Release ) . filter ( <EOL> Release . name == u"<STR_LIT>" <EOL> ) <EOL> self . assertEqual ( len ( list ( check ) ) , <NUM_LIT:1> ) <EOL> def test_yaml_fixture ( self ) : <EOL> data = '''<STR_LIT>''' <EOL> fixman . upload_fixture ( StringIO ( data ) , loader = yaml ) <EOL> check = self . db . query ( Release ) . filter ( <EOL> Release . name == u"<STR_LIT>" <EOL> ) <EOL> self . assertEqual ( len ( list ( check ) ) , <NUM_LIT:1> ) <EOL> check = self . db . query ( Release ) . filter ( <EOL> Release . name == u"<STR_LIT>" <EOL> ) <EOL> self . assertEqual ( len ( list ( check ) ) , <NUM_LIT:0> ) </s>
