def test_build_one_part_only_from_3(self): fake_logger = fixtures.FakeLogger(level=logging.ERROR) self.useFixture(fake_logger) parts = self.make_snapcraft_yaml(n=3) build.main(['build1', ]) self.assertTrue(os.path.exists(common.get_partsdir()), 'Expected a parts directory') self.assertTrue(os.path.exists(parts[1]['part_dir']), 'Expected a part directory for the build1 part') self.assertTrue(os.path.exists(parts[1]['state_file']), 'Expected a state file for the build1 part') with open(parts[1]['state_file']) as sf: state = sf.readlines() self.assertEqual(len(state), 1, 'Expected only one line in the state ' 'file for the build1 part') self.assertEqual(state[0], 'build', "Expected the state file for " " build1 to be 'build'") for i in [0, 2]: self.assertFalse(os.path.exists(parts[i]['part_dir']), 'Pulled wrong part') self.assertFalse(os.path.exists(parts[i]['state_file']), 'Expected for only to be a state file for build1')
def test_build_one_part_only_from_3(self): fake_logger = fixtures.FakeLogger(level=logging.ERROR) self.useFixture(fake_logger) parts = self.make_snapcraft_yaml(n=3) build.main([ 'build1', ]) self.assertTrue(os.path.exists(common.get_partsdir()), 'Expected a parts directory') self.assertTrue(os.path.exists(parts[1]['part_dir']), 'Expected a part directory for the build1 part') self.assertTrue(os.path.exists(parts[1]['state_file']), 'Expected a state file for the build1 part') with open(parts[1]['state_file']) as sf: state = sf.readlines() self.assertEqual( len(state), 1, 'Expected only one line in the state ' 'file for the build1 part') self.assertEqual( state[0], 'build', "Expected the state file for " " build1 to be 'build'") for i in [0, 2]: self.assertFalse(os.path.exists(parts[i]['part_dir']), 'Pulled wrong part') self.assertFalse( os.path.exists(parts[i]['state_file']), 'Expected for only to be a state file for build1')
def test_build_invalid_part(self): fake_logger = fixtures.FakeLogger(level=logging.ERROR) self.useFixture(fake_logger) self.make_snapcraft_yaml() with self.assertRaises(EnvironmentError) as raised: build.main(['no-build', ]) self.assertEqual( raised.exception.__str__(), "The part named 'no-build' is not defined in 'snapcraft.yaml'")
def test_build_defaults(self): fake_logger = fixtures.FakeLogger(level=logging.ERROR) self.useFixture(fake_logger) parts = self.make_snapcraft_yaml() build.main() self.assertTrue(os.path.exists(common.get_partsdir()), 'Expected a parts directory') self.assertTrue(os.path.exists(parts[0]['part_dir']), 'Expected a part directory for the build0 part') self.verify_state('build0', parts[0]['state_dir'], 'build')
def test_build_invalid_part(self): fake_logger = fixtures.FakeLogger(level=logging.ERROR) self.useFixture(fake_logger) self.make_snapcraft_yaml() with self.assertRaises(EnvironmentError) as raised: build.main([ 'no-build', ]) self.assertEqual( raised.exception.__str__(), "The part named 'no-build' is not defined in 'snapcraft.yaml'")
def test_build_one_part_only_from_3(self): fake_logger = fixtures.FakeLogger(level=logging.ERROR) self.useFixture(fake_logger) parts = self.make_snapcraft_yaml(n=3) build.main(['build1', ]) self.assertTrue(os.path.exists(common.get_partsdir()), 'Expected a parts directory') self.assertTrue(os.path.exists(parts[1]['part_dir']), 'Expected a part directory for the build1 part') self.verify_state('build1', parts[1]['state_dir'], 'build') for i in [0, 2]: self.assertFalse(os.path.exists(parts[i]['part_dir']), 'Pulled wrong part') self.assertFalse(os.path.exists(parts[i]['state_dir']), 'Expected for only to be a state file for build1')
def test_build_defaults(self): fake_logger = fixtures.FakeLogger(level=logging.ERROR) self.useFixture(fake_logger) parts = self.make_snapcraft_yaml() build.main() self.assertTrue(os.path.exists(common.get_partsdir()), 'Expected a parts directory') self.assertTrue(os.path.exists(parts[0]['part_dir']), 'Expected a part directory for the build0 part') self.assertTrue(os.path.exists(parts[0]['state_file']), 'Expected a state file for the build0 part') with open(parts[0]['state_file']) as sf: state = sf.readlines() self.assertEqual(len(state), 1, 'Expected only one line in the state ' 'file for the build0 part') self.assertEqual(state[0], 'build', "Expected the state file for " "build0 to be 'build'")
def test_build_defaults(self): fake_logger = fixtures.FakeLogger(level=logging.ERROR) self.useFixture(fake_logger) parts = self.make_snapcraft_yaml() build.main() self.assertTrue(os.path.exists(common.get_partsdir()), 'Expected a parts directory') self.assertTrue(os.path.exists(parts[0]['part_dir']), 'Expected a part directory for the build0 part') self.assertTrue(os.path.exists(parts[0]['state_file']), 'Expected a state file for the build0 part') with open(parts[0]['state_file']) as sf: state = sf.readlines() self.assertEqual( len(state), 1, 'Expected only one line in the state ' 'file for the build0 part') self.assertEqual(state[0], 'build', "Expected the state file for " "build0 to be 'build'")