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