Exemplo n.º 1
0
 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."
         )
Exemplo n.º 2
0
    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.")
Exemplo n.º 3
0
 def test_empty_snippet(self):
     s = Snippet()
     s.save()
     self.assertEqual(str(s), "")
Exemplo n.º 4
0
 def test_footer_snippet(self):
     s = Snippet(footer="testing")
     s.save()
     self.assertEqual(str(s.footer), "testing")
Exemplo n.º 5
0
 def test_body_snippet(self):
     s = Snippet(body="testing")
     s.save()
     self.assertEqual(str(s.body), "testing")
Exemplo n.º 6
0
 def test_header_snippet(self):
     s = Snippet(header="testing")
     s.save()
     self.assertEqual(str(s.header), "testing")
Exemplo n.º 7
0
 def test_alias_snippet(self):
     s = Snippet(alias="testing")
     s.save()
     self.assertEqual(str(s.alias), "testing")
Exemplo n.º 8
0
 def test_title_snippet(self):
     s = Snippet(title="testing")
     s.save()
     self.assertEqual(str(s), "testing")
Exemplo n.º 9
0
 def test_empty_snippet(self):
     s = Snippet()
     s.save()
     self.assertEqual(str(s), "")
Exemplo n.º 10
0
 def test_footer_snippet(self):
     s = Snippet(footer="testing")
     s.save()
     self.assertEqual(str(s.footer), "testing")
Exemplo n.º 11
0
 def test_body_snippet(self):
     s = Snippet(body="testing")
     s.save()
     self.assertEqual(str(s.body), "testing")
Exemplo n.º 12
0
 def test_header_snippet(self):
     s = Snippet(header="testing")
     s.save()
     self.assertEqual(str(s.header), "testing")
Exemplo n.º 13
0
 def test_alias_snippet(self):
     s = Snippet(alias="testing")
     s.save()
     self.assertEqual(str(s.alias), "testing")
Exemplo n.º 14
0
 def test_title_snippet(self):
     s = Snippet(title="testing")
     s.save()
     self.assertEqual(str(s), "testing")