def testRepr(self):
     self.assertEqual(
         repr(self.zp), "\n".join([
             '%s ' % DEFAULT_NAME,  # the space is important at the end
             '\tAUTHOR: %s' % defaults.get('author'),
             '\tVERSION: %s' % defaults.get('version'),
             '\tLICENSE: %s' % defaults.get('license', 'GPL')]))
 def test_processTemplate(self):
     dc = self.zp.addDeviceClass('Devices/Example')
     dc.addComponentType('Component')
     for cjs in self.zp.componentJSs.values():
         self.write(cjs, '${zenpack.id}\n${zenpack.version}\n')
         version = defaults.get('version')
         self.assertEqual(self.results[-1], call(u'a.b.c\n%s\n' % version))
 def test_processTemplate(self):
     dc = self.zp.addDeviceClass('Devices/Example')
     dc.addComponentType('Component')
     for cjs in self.zp.componentJSs.values():
         self.write(cjs, '${zenpack.id}\n${zenpack.version}\n')
         version = defaults.get('version')
         self.assertEqual(self.results[-1], call(u'a.b.c\n%s\n' % version))
    def test_directoryLayout(self):
        m = mock_open()
        dl = self.zp.destdir
        with patch('__builtin__.open', mock_open(read_data='fake data'), create=True) as m:
            dl.write()
            # Write File Handle
            wfh = m.return_value.__enter__.return_value
            self.results = wfh.write.call_args_list

            # Get the specific file calls that make up our writes
            top = defaults.get('prefix', os.getcwd())
            name = DEFAULT_NAME
            file_calls = [x
                          for x in m.mock_calls
                          if repr(x)[6:].startswith("%s/%s" % (top, name))]
            self.assertEqual(
                self.results, [
                    call(
                        "__import__('pkg_resources').declare_namespace(__name__)\n"),
                    call(
                        "__import__('pkg_resources').declare_namespace(__name__)\n"),
                    call(
                        "__import__('pkg_resources').declare_namespace(__name__)\n"),
                    call('graft ZenPacks\n')])
            self.assertEqual(
                file_calls, [
                    call('%s/%s/a/__init__.py' % (top, name), 'w'),
                    call('%s/%s/a/b/__init__.py' % (top, name), 'w'),
                    call('%s/%s/a/b/c/__init__.py' % (top, name), 'w'),
                    call('%s/%s/MANIFEST.in' % (top, name), 'w')])
示例#5
0
 def test_WriteBasicAgain(self):
     d = Component(self.zp, 'Component2')
     name = DEFAULT_NAME
     version = defaults.get('version')
     self.write(
         d, '${zenpack.id}\n${zenpack.version}\n${zenpack.version}\n')
     self.assertEqual(self.results[-1], call(
         u'%s\n%s\n%s\n' % (DEFAULT_NAME, version, version)))
 def test_default(self):
     package_license = str(self.zp.license)
     defaults_license = str(License(defaults.get("license", '')))
     self.assertEqual(package_license, defaults_license)
 def test_templateCacheLocation(self):
     t = Template(self.zp)
     t.dest_file = 'foo.py'
     top = defaults.get('prefix', os.getcwd())
     self.assertEqual(t.TemplateCacheLocation(),
                      '%s/%s/Templates/foo.py.tmpl' % (top, DEFAULT_NAME2))
 def test_processTemplate(self):
     t = Template(self.zp)
     self.write(t, '${zenpack.id}\n${zenpack.version}\n')
     name = DEFAULT_NAME
     version = defaults.get('version')
     self.assertEqual(self.results[-1], call(u'%s\n%s\n' % (name, version)))
示例#9
0
 def test_processTemplate(self):
     self.write(self.zp.rootinit, '${zenpack.id}\n${zenpack.version}\n')
     name = DEFAULT_NAME
     version = defaults.get('version')
     self.assertEqual(self.results[-1], call(u'%s\n%s\n' % (name, version)))
示例#10
0
 def test_WriteBasic(self):
     c = Component(self.zp, 'Component')
     self.write(c, '${zenpack.id}\n${zenpack.version}\n')
     version = defaults.get('version')
     name = DEFAULT_NAME
     self.assertEqual(self.results[-1], call(u'%s\n%s\n' % (name, version)))