예제 #1
0
    def test_init_with_existing_snapcraft_yaml_must_fail(self):
        fake_logger = fixtures.FakeLogger(level=logging.ERROR)
        self.useFixture(fake_logger)

        open("snapcraft.yaml", "w").close()

        with self.assertRaises(SystemExit) as raised:
            cmds.init("dummy args")
        self.assertEqual(raised.exception.code, 1, "Wrong exit code returned.")
        self.assertEqual("snapcraft.yaml already exists!\n", fake_logger.output)
예제 #2
0
    def test_init_without_parts_must_write_snapcraft_yaml(self):
        fake_logger = fixtures.FakeLogger(level=logging.INFO)
        self.useFixture(fake_logger)

        snap_without_parts = type('obj', (object, ), {'part': []})
        with self.assertRaises(SystemExit) as raised:
            cmds.init(snap_without_parts)

        self.assertEqual(raised.exception.code, 0, 'Wrong exit code returned.')
        self.assertEqual('Wrote the following as snapcraft.yaml.\n',
                         fake_logger.output)
예제 #3
0
    def test_init_with_existing_snapcraft_yaml_must_fail(self):
        fake_logger = fixtures.FakeLogger(level=logging.ERROR)
        self.useFixture(fake_logger)

        open('snapcraft.yaml', 'w').close()

        with self.assertRaises(SystemExit) as raised:
            cmds.init('dummy args')
        self.assertEqual(raised.exception.code, 1, 'Wrong exit code returned.')
        self.assertEqual('snapcraft.yaml already exists!\n',
                         fake_logger.output)
예제 #4
0
    def test_init_without_parts_must_write_snapcraft_yaml(self):
        fake_logger = fixtures.FakeLogger(level=logging.INFO)
        self.useFixture(fake_logger)

        snap_without_parts = type('obj', (object, ), {'part': []})
        with self.assertRaises(SystemExit) as raised:
            cmds.init(snap_without_parts)

        self.assertEqual(raised.exception.code, 0, 'Wrong exit code returned.')
        self.assertEqual(
            'Wrote the following as snapcraft.yaml.\n',
            fake_logger.output)
예제 #5
0
    def test_init_without_parts_must_write_snapcraft_yaml(self, mock_stdout):
        fake_logger = fixtures.FakeLogger(level=logging.INFO)
        self.useFixture(fake_logger)

        snap_without_parts = type("obj", (object,), {"part": []})
        with self.assertRaises(SystemExit) as raised:
            cmds.init(snap_without_parts)

        self.assertEqual(raised.exception.code, 0, "Wrong exit code returned.")
        self.assertEqual("Wrote the following as snapcraft.yaml.\n", fake_logger.output)

        expected_out = """
name: # the name of the snap
version: # the version of the snap
# The vendor for the snap (replace 'Vendor <*****@*****.**>')
vendor: Vendor <*****@*****.**>
summary: # 79 char long summary
description: # A longer description for the snap
icon: # A path to an icon for the package
"""
        self.assertEqual(mock_stdout.getvalue(), expected_out)
예제 #6
0
    def test_init_without_parts_must_write_snapcraft_yaml(self, mock_stdout):
        fake_logger = fixtures.FakeLogger(level=logging.INFO)
        self.useFixture(fake_logger)

        snap_without_parts = type('obj', (object, ), {'part': []})
        with self.assertRaises(SystemExit) as raised:
            cmds.init(snap_without_parts)

        self.assertEqual(raised.exception.code, 0, 'Wrong exit code returned.')
        self.assertEqual('Wrote the following as snapcraft.yaml.\n',
                         fake_logger.output)

        expected_out = '''
name: # the name of the snap
version: # the version of the snap
# The vendor for the snap (replace 'Vendor <*****@*****.**>')
vendor: Vendor <*****@*****.**>
summary: # 79 char long summary
description: # A longer description for the snap
icon: # A path to an icon for the package
'''
        self.assertEqual(mock_stdout.getvalue(), expected_out)