def handle(self, *args, **options): """Iterate throw the list to create the snippets.""" if args: s = Snippet(title=args[0]) if options["header"]: s.header = options["header"].read() # else: # with open('farinha/header.txt', 'r') as f: # s.header = f.read() if options["body"]: s.body = options["body"].read() # else: # with open('farinha/body.txt', 'r') as f: # s.body = f.read() if options["footer"]: s.footer = options["footer"].read() # else: # with open('farinha/footer.txt', 'r') as f: # s.footer = f.read() s.save() else: self.stdout.write( "You need to provide at least the snippet's \ title." )
def handle(self, *args, **options): """Iterate throw the list to create the snippets.""" if args: s = Snippet(title=args[0]) if options['header']: s.header = options['header'].read() # else: # with open('farinha/header.txt', 'r') as f: # s.header = f.read() if options['body']: s.body = options['body'].read() # else: # with open('farinha/body.txt', 'r') as f: # s.body = f.read() if options['footer']: s.footer = options['footer'].read() # else: # with open('farinha/footer.txt', 'r') as f: # s.footer = f.read() s.save() else: self.stdout.write("You need to provide at least the snippet's \ title.")
def test_empty_snippet(self): s = Snippet() s.save() self.assertEqual(str(s), "")
def test_footer_snippet(self): s = Snippet(footer="testing") s.save() self.assertEqual(str(s.footer), "testing")
def test_body_snippet(self): s = Snippet(body="testing") s.save() self.assertEqual(str(s.body), "testing")
def test_header_snippet(self): s = Snippet(header="testing") s.save() self.assertEqual(str(s.header), "testing")
def test_alias_snippet(self): s = Snippet(alias="testing") s.save() self.assertEqual(str(s.alias), "testing")
def test_title_snippet(self): s = Snippet(title="testing") s.save() self.assertEqual(str(s), "testing")