def test_register_and_find(self): ''' Test that License classes can be registered with id ''' class FooLicense(base.License): id = 'FOO' licenraptor.register(FooLicense) assert licenraptor.find('FOO') == FooLicense
def test_header(self, id): ''' Test that License classes with header render it ''' email = '*****@*****.**' header = licenraptor.find(id).header(name='Petr Foo', email=email) assert email in header assert str(date.today().year) in header assert 'This program is free software' in header
def test_render(self, name): ''' Test that License classes can render it's files ''' email = '*****@*****.**' text = licenraptor.find('MIT').render(name=name, email=email) assert name in text assert email in text assert str(date.today().year) in text assert 'Permission is hereby granted' in text
def test_register_find_custom_license(self): ''' Test that custom license can be registered and found ''' try: licenraptor.register(self.custom_cls) assert licenraptor.find('CUSTOM') == self.custom_cls finally: # unregister, just in case try: del licenraptor.core._db['CUSTOM'] except: pass
def test_exisitng(self, id): ''' Test that an exisitng license can be found ''' assert licenraptor.find(id).id == id
def test_nonexisting(self): ''' Test that non-existing license cannot be found ''' with pytest.raises(KeyError): licenraptor.find('This is not an existing SPDX identifier')
def test_render_undefined(self): ''' Test that License classes will fail to render without all variables defined ''' with pytest.raises(jinja2.UndefinedError): licenraptor.find('MIT').render(name='xx')
def test_header_no_template(self): ''' Test that License classes without header templates raise AttributeError during .header() ''' with pytest.raises(AttributeError): header = licenraptor.find('MIT').header()