Пример #1
0
 def test_main(self, stdout):
     sys.stdout = stdout
     with tempDockerfile(self.content) as fd:
         args = ['dockerfile', '-f', fd.name, '-o', '-t', 'new.tag']
         tested_module.main(args)
         stdout.write.mock_calls.should.eql([
             mock.call(
                 '\n'.join([
                     'FROM image:new.tag',
                     'ADD  file /folder/',
                     'RUN touch /var/lib/rpm/* && apt-get update &&  '
                     'yum install package &&  apt-get install package '
                     '&& apt-get clean && yum clean all',
                     'FROM other-image:new.tag',
                     'ADD  some.file /other.folder/',
                     'RUN  something',
                 ])
             ),
             mock.call('\n'),
         ])
Пример #2
0
    def test_main(self, dockerfile):
        tested_module.main(['dockerfile', '-f', 'some.folder/file'])
        dockerfile.assert_called_with(
            ['some.folder/file'],
            newTag=mock.ANY, optimizeLayers=mock.ANY, single=mock.ANY
        )
        dockerfile.reset_mock()

        tested_module.main(['dockerfile', 'some.file'])
        dockerfile.assert_called_with(
            ['some.file'],
            newTag=mock.ANY, optimizeLayers=mock.ANY, single=mock.ANY
        )
        dockerfile.reset_mock()

        tested_module.main(['dockerfile'])
        dockerfile.assert_called_with(
            ['Dockerfile'],
            newTag=mock.ANY, optimizeLayers=mock.ANY, single=mock.ANY
        )