test_neocities.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import unittest
  2. import os
  3. import neocities
  4. # Bonus: Running these tests enough times will likely get you banned!
  5. class NeoCitiesTestCase(unittest.TestCase):
  6. def setUp(self):
  7. auth = (os.environ['NEOCITIES_USER'],
  8. os.environ['NEOCITIES_PASS'])
  9. self.nc = neocities.NeoCities(*auth)
  10. def test_info_no_auth(self):
  11. self.nc = neocities.NeoCities()
  12. response = self.nc.info('blog')
  13. self.assertEqual(response['result'], 'success')
  14. """
  15. Tests from this point on require you to have a NeoCities.org account
  16. """
  17. def test_info_auth(self):
  18. response = self.nc.info()
  19. self.assertEqual(response['result'], 'success')
  20. def test_upload_and_delete(self):
  21. """
  22. I would usually refrain from testing multiple things at once but order
  23. is very important in this case
  24. """
  25. response = self.nc.upload(('tests/fixtures/cat.png', 'neko.png'),
  26. ('tests/fixtures/gpl.html', 'gpl.html'))
  27. self.assertEqual(response['result'], 'success')
  28. response = self.nc.delete('neko.png', 'gpl.html')
  29. self.assertEqual(response['result'], 'success')